安裝(終端)
1.安裝Xcode Command Line Tools
xcode-select --install
未安裝有彈窗,點(diǎn)擊安裝.
提示
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
為已安裝
2.安裝fastlane
sudo gem install fastlane
2.1安裝fir插件
fastlane add_plugin fir_cli
為了確保所有插件保持最新, 建議您定期運(yùn)行
fastlane install_plugins
2.2 安裝蒲公英插件
初始化
cd到項(xiàng)目根目錄,初始化fastlane
fastlane init
- tip1
What would you like to use fastlane for?
//自動(dòng)化截圖
1\. ?? Automate screenshots
//TestFlight
2\. ???? Automate beta distribution to TestFlight
//APP store
3\. ?? Automate App Store distribution
//手動(dòng)設(shè)置項(xiàng)目自動(dòng)化任務(wù)
4\. ?? Manual setup - manually setup your project to automate your tasks
我這里選擇的是3
- tip2
Please enter your Apple ID developer credentials
Apple ID Username:
需要填寫你需要使用的開發(fā)者賬號
- tip3
Logging in...
Multiple App Store Connect teams found, please enter the number of the team you want to use:
如果該賬號下有多個(gè)team,需要選擇正確的填寫序號
- tip4
Multiple teams found on the Developer Portal, please enter the number of the team you want to use:
開發(fā)者門戶上有多個(gè)團(tuán)隊(duì),請輸入您要使用的團(tuán)隊(duì)編號
提問了你的Apple ID,Team的問題之后,fastlane會(huì)自動(dòng)檢測當(dāng)前目錄下項(xiàng)目的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
這一步如果沒有改鏡像會(huì)比較慢甚至失敗(失敗提示如下,其他成功),等結(jié)束可以修改鏡像或者重新 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
成功后,項(xiàng)目根目錄多出fastlane文件夾,文件大致結(jié)構(gòu)如下
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任務(wù)Fastfile幫助
- Appfile => 是用來存儲(chǔ)一些公共信息的,比如
app_identifier,apple_id,team_id,itc_team_id等。Appfile幫助 - Deliverfile =>
deliver的配置文件Deliverfile幫助
插件
Fastlane的插件是一個(gè)或者一組action的打包,單獨(dú)發(fā)布在fastlane之外。
fastlane search_plugins //用來查看當(dāng)前fastlane支持的插件
fastlane-plugin-versioning //用來修改build版本號和version版本號。
fastlane add_plugin versioning
配置發(fā)布流程
發(fā)布到App Store
Lane
寫入fastlane文件夾下的Fastfile文件中,command + s
lane :deploy do
# 如果項(xiàng)目 pod install
cocoapods
# 不帶adhoc參數(shù),sigh會(huì)自動(dòng)生成App Store證書(公司或個(gè)人帳戶)
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
運(yùn)行
bundle exec fastlane deploy //deploy為lane的name
如果你的賬號開啟了雙重驗(yàn)證,會(huì)提示紅色
[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 你的開發(fā)者賬號):