安装(终端)
1.安装Xcode Command Line Tools
xcode-select --install
未安装有弹窗,点击安装.
提示
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
为已安装
2.安装fastlane
sudo gem install fastlane
2.1安装fir插件
关于 fir.im fastlane 插件的一些说明 (betaqr.com)
fastlane add_plugin fir_cli
为了确保所有插件保持最新, 建议您定期运行
fastlane install_plugins
2.2 安装蒲公英插件
蒲公英 - 文档中心 - 使用 Fastlane 上传 App 到蒲公英 (pgyer.com)
初始化
cd到项目根目录,初始化fastlane
fastlane init
- tip1
What would you like to use fastlane for?
//自动化截图
1\. Automate screenshots
//TestFlight
2\. ✈️ Automate beta distribution to TestFlight
//APP store
3\. Automate App Store distribution
//手动设置项目自动化任务
4\. Manual setup - manually setup your project to automate your tasks
我这里选择的是3
- tip2
Please enter your Apple ID developer credentials
Apple ID Username:
需要填写你需要使用的开发者账号
- tip3
Logging in...
Multiple App Store Connect teams found, please enter the number of the team you want to use:
如果该账号下有多个team,需要选择正确的填写序号
- tip4
Multiple teams found on the Developer Portal, please enter the number of the team you want to use:
开发者门户上有多个团队,请输入您要使用的团队编号
提问了你的Apple ID
,Team
的问题之后,fastlane会自动检测当前目录下项目的App Name
和App Identifier
。如果检测的不对,选择n
自行输入。
- tip5
Would you like fastlane to manage your app's metadata? (y/n)
y
- tip6
Installing dependencies for you...
$ bundle update
这一步如果没有改镜像会比较慢甚至失败(失败提示如下,其他成功),等结束可以修改镜像或者重新 bundle update
Could not fetch specs from https://rubygems.org/
Exit status: 17
Something went wrong when running `bundle update` for you
Please take a look at your Gemfile at path `Gemfile` and make sure you can run `bundle update` on your machin
成功后,项目根目录多出fastlane文件夹,文件大致结构如下
fastlane
├── Appfile
├── Deliverfile
├── Fastfile
├── metadata
│ ├── copyright.txt
│ ├── en-US
│ │ ├── description.txt
│ │ ├── keywords.txt
│ │ └── 等若干txt文件
│ ├── primary_category.txt
│ ├── primary_first_sub_category.txt
│ ├── primary_second_sub_category.txt
│ ├── secondary_category.txt
│ ├── secondary_first_sub_category.txt
│ └── secondary_second_sub_category.txt
└── screenshots
└── README.txt
- Fastfile => 用来定义所有的lane任务Fastfile帮助
- Appfile => 是用来存储一些公共信息的,比如
app_identifier
,apple_id
,team_id
,itc_team_id
等。Appfile帮助 - Deliverfile =>
deliver
的配置文件Deliverfile帮助
插件
Fastlane的插件是一个或者一组action
的打包,单独发布在fastlane之外。
fastlane search_plugins //用来查看当前fastlane支持的插件
fastlane-plugin-versioning //用来修改build版本号和version版本号。
fastlane add_plugin versioning
配置发布流程
发布到App Store
Lane
写入fastlane文件夹下的Fastfile文件中,command + s
lane :deploy do
# 如果项目 pod install
cocoapods
# 不带adhoc参数,sigh会自动生成App Store证书(公司或个人帐户)
sigh
increment_build_number_in_plist(target: [target_name])
increment_version_number_in_plist(
target: [target_name],
version_number: '1.0.0'
)
# 指定输出目录
gym(
output_directory: './build',
)
# 上传所有信息到App Store
deliver(force: true)
end
运行
bundle exec fastlane deploy //deploy为lane的name
如果你的账号开启了双重验证,会提示红色
[Transporter Error Output]: Please sign in with an app-specific password. You can create one at appleid.apple.com. (-22910)
Transporter transfer failed.
Please sign in with an app-specific password. You can create one at appleid.apple.com. (-22910)
Your account has 2 step verification enabled
Please go to https://appleid.apple.com/account/manage
and generate an application specific password for
the iTunes Transporter, which is used to upload builds
To set the application specific password on a CI machine using
an environment variable, you can set the
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD
填写账号的APP专用密码(https://appleid.apple.com/account/manage)
Password (application-specific for 你的开发者账号):