#前言
我們公司一直使用fir.im平臺來托管應用內(nèi)測。按照之前的內(nèi)測方法步驟:
*Product->Archive
*導出ipa文件
*上傳到fim
*生成二維碼鏈接
一套流程下來,半個小時沒了。費時費力,而且有時候一個細微的改動,又需要重新打包。
最近接觸到fastlane自動化打包,感覺很方便,可以節(jié)省不少時間。Fastlane GitHub地址
1.打開終端 檢查是否安裝ruby
ruby -v
2.檢查是否安裝Xcode命令行工具
xcode-select --install????????????????????????????????
未安裝則會彈出下圖:

點擊安裝
如果已經(jīng)安裝了則會提示
command line tools are already installed, use "Software Update" to install updates.
3.安裝fastlane
????sudo gem install fastlane
提示你輸入密碼

4.初始化fastlane到你的工程項目中
cd ?拖入你的工程項目文件,然后
fastlane init

1.Automate screenshots:自動截屏;
2.Automate beta distribution to TestFlight:自動發(fā)布 beta 版本用于 TestFlight;
3.Automate App Store distribution:自動發(fā)布到 AppStore;
4.手動設置
我選擇的4.手動設置

5.打包文件配置
fastlane在你的項目初始化成功后,會在你的項目中生成一個文件夾fastlane,里面包含兩個文件Appfile和Fastfile
?1.Appfile文件配置
# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app
# apple_id("[[APPLE_ID]]") # Your Apple email address
# For more information about the Appfile, see:
#? ? https://docs.fastlane.tools/advanced/#appfile
雙擊打開Appfile文件,#后面說的很清楚了,就是你工程的Bundle Identifer 和你的Apple ID直接修改后com+s保存就行了
2.Fastfile文件配置

scheme:就是你工程的名字?
export_method:輸出類型
output_dircttory:導出文件所在的文件夾路徑
firim_api_token:fir.im的token
不添加fir.im的token無法自動上傳到fir

打開fir的token獲取登錄后如上圖可以獲取fir.im的token
6.自動上傳fir配置
安裝fir插件
fastlane add_plugin fir
自動上傳到fir
gem install fir-cli
7.執(zhí)行自動化打包并上傳至fir
fastlane test_name
test_name是你Fastfile文件中l(wèi)ane后的名字,具體跟你自己定義的名字進行打包命令
上傳成功如下圖

8.遇到的問題
Could not find action, lane or variable 'firim'. Check out the documentation for more details:?https://docs.fastlane.tools/actions?報錯這個問題找不到fir.im
使用如下命令重新安裝fir插件
fastlane add_plugin firim
還是報
Make sure that `gem install firim -v '0.2.0' --source 'https://rubygems.org/'`
succeeds before bundling.
貌似是沒權限的緣故,最后用如下命令解決
sudo fastlane add_plugin firim
9.總結
第一次使用fastlane,感覺打包分發(fā)方便了很多。且記錄下來,歡迎大家交流QQ:869373063?
自動化打包貌似Jenkins和fir.im提供也不錯,大家也可以嘗試。