Fastlane是一套使用Ruby寫(xiě)的自動(dòng)化工具集秀菱,旨在簡(jiǎn)化Android和iOS的部署過(guò)程柿菩,自動(dòng)化你的工作流戚嗅。它可以簡(jiǎn)化一些乏味、單調(diào)枢舶、重復(fù)的工作懦胞,像截圖、代碼簽名以及發(fā)布App凉泄。
通過(guò)配置自動(dòng)上傳到蒲公英,fir.im內(nèi)測(cè)平臺(tái)進(jìn)行測(cè)試分發(fā)躏尉,也可以直接上傳到TestFlight,iTunes Connect后众。
多說(shuō)無(wú)益胀糜,開(kāi)始上手
一颅拦、安裝xcode命令行工具
xcode-select --install //如果沒(méi)有安裝,會(huì)彈出對(duì)話(huà)框教藻,點(diǎn)擊安裝距帅。如果提示xcode-select: error: command line tools are already installed, use "Software Update" to install updates表示已經(jīng)安裝
二、安裝Fastlane
sudo gem install fastlane -NV或是brew cask install fastlane我這里使用gem安裝的
安裝完了執(zhí)行fastlane --version括堤,確認(rèn)下是否安裝完成和當(dāng)前使用的版本號(hào)碌秸。
三、初始化Fastlane
cd到你的項(xiàng)目目錄執(zhí)行
fastlane init
然后彈出4個(gè)選項(xiàng)
What would you like to use fastlane for?
1. Automate screenshots //截屏
2. Automate beta distribution to TestFlight //自動(dòng)發(fā)布beta版本用于TestFlight
3. Automate App Store distribution //自動(dòng)的App Store發(fā)布包
4. Manual setup - manually setup your project to automate your tasks //手動(dòng)設(shè)置
我選擇了4悄窃,接著一路回車(chē)搞定
四哮肚、文件系統(tǒng)
通過(guò)上面的一頓猛操作后,生成了我們熟悉的fastlane目錄广匙,該目錄下包含了Appfile和Fastfile。我們打開(kāi)這兩個(gè)文件恼策。
- Appfile
app_identifier("自己的項(xiàng)目的bundle_id") # The bundle identifier of your app
apple_id("自己項(xiàng)目的蘋(píng)果開(kāi)發(fā)者賬號(hào)") # Your Apple email address
# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile
- Fastfile
fastlane的最主要的文件鸦致,在這個(gè)文件中可以編寫(xiě)我們需要使用的各個(gè)工具的順序、方式等涣楷。
下面看一個(gè)自動(dòng)發(fā)布到蒲公英的Fastfile文件:
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
desc "打包到pgy"
lane :beta do
gym(
clean:true, #打包前clean項(xiàng)目
export_method: "ad-hoc", #導(dǎo)出方式
scheme:"XXXXX", #scheme
configuration: "Release",#環(huán)境
output_directory:"/Users/tiankongxiyinwo/Desktop/測(cè)試包",#ipa的存放目錄
output_name:"文件名"#輸出ipa的文件名
)
#蒲公英的配置 替換為自己的api_key和user_key
pgyer(api_key: "xxxxxxxxxxxxxxxxxxx", user_key: "xxxxxxxxxxxxxxxxxxx")
end
end
大家看到pgyer(api_key: "xxxxxxxxxxxxxxxxxxx", user_key: "xxxxxxxxxxxxxxxxxxx")命令分唾,很明顯這是蒲公英語(yǔ)法,所以接下在安裝蒲公英插件
五狮斗、安裝插件
- 安裝蒲公英的 Fastlane 插件
fastlane add_plugin pgyer
還有好多插件這里就不介紹了绽乔。
六、執(zhí)行
fastlane bate