fastlane自动化打包ipa并发布到firim或者蒲公英

1.打开终端,确保Xcode Command Line Tools 安装了最新版

xcode-select --install

2.安装fastlane

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

查看源  gem sources -l   卡住不动,可能Ruby的源被墙了,

移除源  gem source -r https://rubygems.org/ (刚才查看到的源)

添加源  gem source -a https://gems.ruby-china.com

备注:https://gems.ruby-china.org 域名改了要用.com 

3.CD到工程目录初始化

fastlane init

初始化的过程中会出现下面的选项:

What would you like to use fastlane for?

1. Automate screenshots

2. Automate beta distribution to TestFlight

3. Automate App Store distribution

4. Manual setup - manually setup your project to automate your tasks

第一个:截图

第二个:发布到TestFlight

第三个:发布到App Store

第四个:手动设置

我们选择4,enter

安装成功会在工程根目录下生成fastlane文件, 包含Appfile和Fastfile配置文件

4.配置Appfile

app_identifier 包名

apple_id 苹果开发者账号

5.配置Fastfile

DemoTest为工程名称

如果工程用了CocoaPods,切记需要配置workspace这个参数,没有用的话,去掉workspace这行即可

firim_api_token: '***************'

firim_api_token 你在firim网站登录后,点击头像,可以查看API token。复制到这地方

备注:如果是蒲公英平台,将firim这行替换为以下蒲公英的配置即可。 pgyer(api_key: "************", user_key: "***********")

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

desc下面的lane后面的 archive 这个方法名可以自由配置,一会发布到firim需要调用此方法。

desc "ipa打包"

lane :archive do
#打包的ipa存放路径
outputDir = "~/firim/ipa/#{Time.now.strftime('%y%m%d')}"
#打包的ipa名称
outputName = "DemoTest-#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"
gym(
scheme: "DemoTest", #改为你项目的scheme
workspace: "DemoTest.xcworkspace", #如果项目使用CocoaPods需要加上
clean: true,
configuration: "Release",
output_directory: outputDir,
output_name: outputName,
include_bitcode: true,
include_symbols: true,
silent: true,
export_method:"development"
)
#上传ipa到fir.im服务器,在fir.im获取firim_api_token
firim(firim_api_token: '你在firim网站登录后,点击头像,可以查看API token。复制到这地方')
end

释义:

6.安装fir插件

fastlane add_plugin firim

备注:如果是蒲公英平台需要输入 fastlane add_plugin pgyer

7.发布到firim

fastlane archive

命令执行完成后, 可以在Fastfile文件output_directory参数配置的目录下找到自动生成的ipa文件,和dYSM的压缩包(如果configuration配置的是Debug,就不会有dYSM的压缩包)

原文地址:https://www.cnblogs.com/huangzs/p/10042793.html