fastlane 是一款為 iOS 和 Android 開發(fā)者提供的自動化構(gòu)建工具合是,它可以幫助開發(fā)者將 App 打包了罪、簽名、測試聪全、發(fā)布泊藕、信息整理、提交 App Store 等工作完整的連接起來难礼,實(shí)現(xiàn)完全自動化的工作流娃圆,如果使用得當(dāng),可以顯著的提高開發(fā)者的開發(fā)效率鹤竭。
fastlane 官網(wǎng)
fastlane Github
fastlane 文檔
本篇使用的功能是打包上傳到蒲公英和App Store踊餐,馬上開始
一、安裝
安裝ruby
ruby版本要求2.0.0以上
查看版本號
ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16]
安裝Xcode 命令行工具
xcode-select --install
如果有下面的提示表示已經(jīng)安裝
xcode-select: error: command line tools are already
installed, use "Software Update" to install updates
安裝Fastlane
sudo gem install fastlane
安裝完了執(zhí)行fastlane --version臀稚,確認(rèn)下是否安裝完成和當(dāng)前使用的版本號吝岭。
二、Fastlane創(chuàng)建
fastlane初始化
cd到你的項(xiàng)目目錄執(zhí)行命令
fastlane init
[15:21:20]: 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
這個地方會要你選擇吧寺。
1.自動截屏窜管。這個功能能幫我們自動截取APP中的截圖,并添加手機(jī)邊框.
2.自動發(fā)布beta版本用于TestFlight
3.自動的App Store發(fā)布包
4.手動設(shè)置
我這里是選的第4個稚机。自行選擇就好幕帆。
添加蒲公英插件
fastlane add_plugin pgyer
deliver初始化
要上傳App Store需要使用deliver,同樣cd到項(xiàng)目目錄執(zhí)行命令
fastlane deliver init
這個時候fastlane會讓你輸入開發(fā)者賬號和APP的Bundle Identifier,如果Bundle Identifier和iTunes Store中任意一個不存在,deliver會初始化失敗.
成功以后看一下工程都新增了哪兒些目錄
如果沒有通過fastlane deliver init 初始化赖条,Deliverfile失乾、screenshots和metadata是不會生成的
三、發(fā)布
編輯Fastfile
Fastfile是我們最應(yīng)該關(guān)注的文件纬乍,也是我們的工作文件碱茁,接下來編輯Fastfile
default_platform(:ios)
platform :ios do
desc "發(fā)布到蒲公英"
lane :beta do
gym(
clean:true,
scheme:"項(xiàng)目名稱",
export_method:"development",
configuration: "Debug",#環(huán)境
output_directory:"./build",
)
pgyer(
api_key: "xxxxxxxxxxxx",
user_key: "xxxxxxxxxxxx",
update_description: "fix something"
)
end
desc "上傳新版本到 App Store"
lane :release do
gym(
clean:true,
scheme:"項(xiàng)目名稱",
export_method:"app-store",
export_xcargs: "-allowProvisioningUpdates",
output_directory:"./build",
)
deliver(
submit_for_review: false # 提交審核
)
end
end
- clean:是否清空以前的編譯信息
- scheme:自己項(xiàng)目名稱
- export_method:就是我們手動打包時要選擇的那四種(app-store,ad-hoc,enterprise,development)
- configuration:環(huán)境(Debug、Release)
- output_directory:打包后的 ipa 文件存放的目錄
- export_xcargs:訪問鑰匙串
- submit_for_review:是否提交審核,true表示立馬提交審核
- api_key仿贬、user_key:蒲公英信息纽竣,如下圖(蒲公英):
上傳蒲公英
進(jìn)入工程目錄,執(zhí)行命令
fastlane beta
過個幾分種茧泪,就可以把包傳上去了
上傳新版本到 App Store
進(jìn)入工程目錄蜓氨,執(zhí)行命令
fastlane release
這個等的時間要長一些,還會輸入賬號队伟、密碼穴吹,成功以后會在App Store Connect自動創(chuàng)建對應(yīng)的待發(fā)布版本,ipa包也會上傳上去
到這里就結(jié)束了嗜侮,祝大家工作愉快刀荒。