美文网首页iOS笔记
fastlane自动打包蒲公英

fastlane自动打包蒲公英

作者: 狗蛋的春天 | 来源:发表于2021-08-18 11:37 被阅读0次

    安装fastlane

       sudo gem install fastlane -NV -n /usr/local/bin
    

    cd到项目所在目录

      cd ......项目
    

    初始化fastlane

      fastlane init
    

    添加蒲公英的插件

      fastlane add_plugin pgyer
    

    根目录下会生成fastlane文件夹,里面会用到Fastfile文件,至于Appfile可用可不用,我没用到

    项目中两个target,一个测试一个正式环境,下面新建两个lane

          default_platform(:ios)
    
          platform :ios do
    
          #正式环境下的打包
          lane :uploadToPgy do
    
          schemeName = "正式环境下的项目名"
          app_identifier = "正式环境下的bundle id"
          apple_id = "开发者主账号"
          export_method = "ad-hoc"
    
    
          #从蒲公英平台拿到的api_key和user_key
          api_key = "xxx"
          user_key = "x'x"
    
          puts "请输入版本描述:"
          desc = STDIN.gets
    
          puts "开始打包 #{schemeName}"
          # 开始打包
          gym(
               scheme: "#{schemeName}",
               output_name:"#{schemeName}",
               clean:true,
               configuration:"Release",#打包正式环境用release 区别下面
               export_method:"#{export_method}",
                output_directory:"./fastlane/build",
            )
    
            puts "开始上传到蒲公英"
            pgyer(update_description: "#{desc}", api_key: "#{api_key}", user_key: "#{user_key}")
    
            #在上传完ipa后,打开ipa的存放文件夹,起到提示上传完成的作用
            system "open ../fastlane/build"
          end
    
      #测试环境下打包
      lane :uploadToPgyDev do 
        schemeName = "测试环境下的项目target名"
        app_identifier = "测试环境下的bundle id"
        apple_id = "开发者主账号"
        export_method = "ad-hoc"
    
    
        api_key = "xxx"
        user_key = "xx"
    
        puts "请输入版本描述:"
        desc = STDIN.gets
    
       puts "开始打包 #{schemeName}"
        # 开始打包
        gym(
           scheme: "#{schemeName}",
           output_name:"#{schemeName}",
           clean:true,
           configuration:"Debug",#打包测试环境用debug
           export_method:"#{export_method}",
           output_directory:"./fastlane/build",
          )
    
        puts "开始上传到蒲公英"
        pgyer(update_description: "#{desc}", api_key: "#{api_key}", user_key: "#{user_key}")
    
        system "open ../fastlane/build" 
         end
    
      end
    

    cd 到项目 执行下面,会让你选择打包哪个环境1和2

        fastlane 
    

    相关文章

      网友评论

        本文标题:fastlane自动打包蒲公英

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