Xcode自帶的打包已經(jīng)非常智能,而且效率非常高,但是我們總免不了要點(diǎn)擊導(dǎo)出和上傳;所以開發(fā)人員都會(huì)追求自動(dòng)化,Xcode自帶的命令封裝成腳本就可以打包,但是太繁瑣,不夠簡(jiǎn)潔,F(xiàn)astlane封裝了Xcode打包的命令,而且非常的簡(jiǎn)潔,便于上手,下面我們就一起來(lái)學(xué)習(xí)一下。
1.配置
使用fastlane環(huán)境打包,我們得先配置一下環(huán)境,fastlane是基于ruby的,所以我們要有ruby環(huán)境,iOS的項(xiàng)目大都使用cocoapods來(lái)管理第三方庫(kù),所以相信大家都已經(jīng)裝好了ruby環(huán)境。
然后檢查 Xcode 命令行工具是否安裝。在終端窗口中輸入命令:(基本上是一句廢話,因?yàn)閕OS開發(fā)都會(huì)裝Xcode)
xcode-select --install
使用rubygem安裝fastlane
sudo gem install fastlane
2.初始化 fastlane
打開終端,進(jìn)入到你的工程目錄下,執(zhí)行fastlane init;init成功之后,你的目錄下面就會(huì)就多了一個(gè) fastlane目錄,其內(nèi)容如下:

修改Appfile配置
# app_identifier("[[]]") # The bundle identifier of your app
# apple_id("[[]]") # Your Apple email address
# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile
3.提交到fir.im分發(fā)平臺(tái)
首先安裝一下fir.im的插件
fastlane add_plugin firim

然后開始我們的lane配置,每一個(gè)環(huán)境都對(duì)應(yīng)一個(gè)lane,比如development、adhoc、appstore;我們僅舉一下development的例子。
終端進(jìn)入fastlane目錄下,打開Fastfile文件,進(jìn)入編輯狀態(tài)
vi Fastfile
一起看一下development的lane配置
default_platform(:iOS)
platform :iOS do
desc "dev 環(huán)境打包"
lane :lane名 do
# add actions here: https://docs.fastlane.tools/actions
cocoapods
build_ios_app(
silent: true,
clean: true,
scheme:"你的scheme",
export_method:"development",//導(dǎo)出環(huán)境
output_directory:"",//包地址
configuration:"Debug")
firim(
firim_api_token:"",//fir的token,網(wǎng)站查看即可
app_changelog:"測(cè)試一下log")//fir的打包日志描述
end
end
基本上一個(gè)lane就是這樣的配置,終端執(zhí)行命令即可
fastlane ios 你的lane名

4.常見(jiàn)錯(cuò)誤根據(jù)提示,通過(guò)搜索都可以解決,歡迎大家討論。