美文网首页
ios 自动化打包fastlane并上传到蒲公英

ios 自动化打包fastlane并上传到蒲公英

作者: 小学生课代表 | 来源:发表于2021-10-09 17:54 被阅读0次

    一、安装xcode命令行工具

    xcode-select --install,如果没有安装,会弹出对话框,点击安装。如果提示xcode-select: error: command line tools are already installed, use "Software Update" to install updates表示已经安装

    二、安装Fastlane

    sudo gem install fastlane
    安装完了执行fastlane --version,确认下是否安装完成和当前使用的版本号。

    三、初始化Fastlane

    cd到项目目录执行
    fastlane init

    image.png
    1. 自动截屏。这个功能能帮我们自动截取APP中的截图,并添加手机边框.
    2. 自动发布beta版本用于TestFlight
    3. 自动的App Store发布包
    4. 手动设置
      选择4
    • 在项目目录里执行fastlane add_plugin pgyer安装蒲公英插件

    四、配置Fastlane

    通过fastlane init 会出现一个fastlane 的文件夹,里面有两个文件(Appfile和Fastfile)

    1. 首先打开Appfile 编辑,需要你填两个东西,如下
     app_identifier "app的bundle id"    
     apple_id "开发者账号"  
    
    1. 然后打开Fastfile编辑
    default_platform(:ios)
    def updateProjectBuildNumber
    build = get_build_number()
        # => 为当前版本 计算迭代版本号
        lastStr = build[build.length-2..build.length-1]
        puts("*************| 当前build #{lastStr} |*************")
        lastNum = lastStr.to_i + 1
        lastStr = lastNum.to_s
    if lastNum < 10
        lastStr = lastStr.insert(0,"0")
        end
      build = "#{lastStr}"
        puts("*************| 更新build #{build} |*************")
    
    # => 更改项目 build 号
    increment_build_number(
    build_number: "#{build}"
    )
    end
    
    #指定项目的scheme名称
    scheme="hibifen"
    #蒲公英api_key和user_key
    api_key = "3c66xxxxx"
    user_key = "aff3xxxxx"
    configuration = "Debug_Develop_Server"#Debug_Production_Server
    platform :ios do
      desc "Description of what the lane does"#随便填写
      lane :custom_lane do
      updateProjectBuildNumber #更改项目build号
      gym(
        #输出的ipa名称
        output_name:"#{scheme}_#{get_build_number()}",
        # 是否清空以前的编译信息 true:是
        clean:true,
        scheme:scheme,
        # 指定打包方式,Release 或者 Debug
        configuration:"#{configuration}",
        # 指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development
        export_method:"development",
        # 指定输出文件夹
        output_directory:"./build",
        )
      pgyer(api_key: "#{api_key}", user_key: "#{user_key}")
      end
    end
    

    一个lane就是一个任务,custom_lane名字可以自己改,gym是fastlane提供的打包工具

    • pgyer
      api_keyuser_key在蒲公英的文档中应用管理 - App概述 - API

    五、执行

    fastlane custom_lane

    image.png

    相关文章

      网友评论

          本文标题:ios 自动化打包fastlane并上传到蒲公英

          本文链接:https://www.haomeiwen.com/subject/umnqoltx.html