iOS使用fastlane一行命令上传到蒲公英

第一步安装fastlane



1.1安装Xcode命令行工具

 终端执行:xcode-select--install

注:如果没有安装,命令会有提示框,根据提示一步一步安装即可。如果出现以下命令提示,说明已经安装成功:xcode-select: error: command line tools are already installed, use "Software Update" to install updates

1.2 安装fastlane (需要已下载ruby)

sudo gem install fastlane

1.3 检查版本 fastlane(验证是否安装成功)

  fastlane --version

第二步:初始化fastlane


2.1 cd到项目目录下执行 fastlane init

命令执行到最后有What would you like to use fastlane for?提示,此时fastlane列出几个选项,需要我们告诉它使用fastlane需要执行哪种操作:第一种获取App Store的App预览照片。第二种打包上传至TestFlight工具上。第三种打包上传到App Store。第四种自定义打包方式。

以上四种方式根据自己的需要自行选择,本文主要介绍打包上传至第三方平台,所以选择4自定义打包方式。选择完成之后,fastlane会在我们项目中创建fastlane文件。

Appfile是编辑我们相关App和开发者账号信息的,一般不需要我们去手动修改。Fastfile是我们对自动打包这个过程的完整配置,默认的Fastfile文件内容如下: 

!如果出现卡住情况无响应那么很有可能是因为被墙了

解决:首先control+c 在终端检查ruby源 ,

输入命令gem source-l ,

如果不是https://gems.ruby-china.com/ ,替换gem sources--addhttps://gems.ruby-china.com/--removehttps://rubygems.org/

打开工程中的Gemfile文件,source "https://rubygems.org"替换为source "https://gems-china.org"

最后删除fastlane文件夹,打开终端,cd到工程中,再次执行fastlane init。

成功后如图


第三步:打包上传到蒲公英

3.1 安装蒲公英的 fastlane 插件

执行 fastlane add_plugin pgyer    (必须在项目目录下执行)

3.2 编辑Fastlane 的配置文件 fastlane/Fastfile

platform :ios do

  desc "Description of what the lane does"

  lane :custom_lane do

    # add actions here: https://docs.fastlane.tools/actions

  end

lane :pgy do

   gym(

      workspace: “xxx.xcworkspace",

      scheme: "xxx”,

      #打包前clean

      clean: true,

      # Release、Debug、自定义

      configuration: "Debug",

      # app-store, ad-hoc, package, enterprise, development

      export_method: "ad-hoc",

      #文件输出路径

      output_directory: "/Users/ios/Desktop/ipa包",

      # ipa名称

      output_name: "xxx.ipa",

      #是否包含调试符号

      include_symbols: true,

      #是否开启bitcode

      include_bitcode: false,

    )

      # mac上的通知弹窗,通知打包完毕

    notification(app_icon: './fastlane/icon.png', title: 'manager', subtitle: '打包成功,已导出安装包', message: '准备上传至蒲公英……')

    #上传蒲公英,update_description为版本更新描述。

  pgyer(api_key: "xxx",update_description: "测试版本更新") 

 #通知上传成功

    notification(app_icon:"icon.png",title:"LoanManager",subtitle: "IPA上传成功", message: "自动打包完成!")

 end

end

以上的 api_key 请开发者在自己账号下的 应用管理 - App概述 - API 中可以找到,并替换到以上相应的位置。

第四步:打包上传到蒲公英

4.1到项目所在目录,输入以下命令即可:

fastlane pgy


最终成功效果

如何修改蒲公英描述?

Fastfile 文件修改lane

lane :pgy do |op|

   gym(

...

  pgyer(api_key: "xxx",update_description: op[:desc]) 

)

终端调用

fastlane pgy desc:xxxx

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容