一、前置條件
1.通過下面命令查看本機(jī)ruby版本,沒有需要安裝
ruby --version
2.安裝Xcode命令行工具
xcode-select –install
二、安裝fastlane
1.執(zhí)行下面命令安裝fastlane
sudo gem install fastlane
2.檢查是否安裝正確
fastlane --version
三、初始化一個(gè)fastlane
1.cd到你的工程目錄茧痕。cd到你的工程目錄。cd到你的工程目錄恼除。重要的事情說三遍踪旷。
2.執(zhí)行下面命令
fastlane init
3.初始化的過程中會(huì)出現(xiàn)下面的選項(xiàng):
其中對(duì)應(yīng)如下圖
-1. 自動(dòng)截屏。
-2. 自動(dòng)發(fā)布beta版本用于TestFlight
-3. 自動(dòng)的App Store發(fā)布包。
-4. 手動(dòng)設(shè)置令野。
我此處選擇了4手動(dòng)配置舀患,命令繼續(xù)執(zhí)行
4.如果fastlane init卡在了bundle update處,請(qǐng)看第5步气破。如果順利沒卡住构舟,請(qǐng)看第6步。
5.bundle update很慢的解決方案
5.1關(guān)閉終端
5.2打開項(xiàng)目文件夾,找到fastlane init過程中生成的Gemfile文件,并打開(Gemfile文件就在你項(xiàng)目目錄下)
Gemfile部分內(nèi)容一般如下堵幽,我們需要將source源修改,不然被墻很難成功
source "https://rubygems.org"
gem "fastlane"
修改如下
source "https://gems.ruby-china.com"
gem "fastlane"
當(dāng)然弹澎,你也可以換成其他可執(zhí)行的ruby源朴下。
5.3打開終端,cd到當(dāng)前項(xiàng)目,執(zhí)行bundle update命令
bundle update
6.fastlane init成功會(huì)在項(xiàng)目目錄下生成fastlane文件夾,以及Appfile和Fastfile兩個(gè)文件
7.配置Appfile和Fastfile苦蒿。注意通過終端使用 vim命令來修改這倆文件殴胧,不可打開修改。
Appfile修改內(nèi)容如下佩迟。你需要替換app_identifier团滥、apple_id、team_id為你自己的東西报强,其中apple_id灸姊、team_id可以在開發(fā)者網(wǎng)站上找到。
# app_identifier("你的項(xiàng)目identifier") # The bundle identifier of your app
# apple_id("你的開發(fā)者賬號(hào)的郵箱") # Your Apple email address
# team_id("你的開發(fā)者賬號(hào)的team_id")
# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile
Fastfile修改內(nèi)容如下秉溉。你需要替換api_key和user_key為你自己的東西力惯。api_key和user_key都在蒲公英賬戶信息里可以查到。
# 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 "Description of what the lane does"
lane :custom_lane do
# add actions here: https://docs.fastlane.tools/actions
build_app(export_method: "ad-hoc")
pgyer(api_key: "蒲公英分配的api_key", user_key: "蒲公英分配的user_key")
end
end
四召嘶、配置蒲公英插件
1. cd到工程目錄下父晶,安裝蒲公英插件。插件安裝好后弄跌,工程的fastlane目錄下會(huì)多出 Gemfile甲喝、Gemfile.lock 、Plugfile這三個(gè)文件铛只。
fastlane add_plugin pgyer
五埠胖、打包上傳到蒲公英
1. cd到工程目錄下,執(zhí)行下面命令(注意格仲,custom_lane為Fastfile文件里的 lane :custom_lane do中間的custom_lane押袍。如果此處你寫什么你就把下面命令替換為什么。比如你寫的是lane :test do,那么就執(zhí)行 fastlane test )
fastlane custom_lane
2. 等到出現(xiàn)下圖后凯肋,就可以去蒲公英上查看最新的打包二維碼了谊惭。
六、錯(cuò)誤處理
如果出現(xiàn) PGYER Plugin Error: ,那是因?yàn)槠压⑵脚_(tái)安裝APP是需要密碼圈盔,如下更改配置就行
之前的配置
pgyer(api_key: "6xxxxxxxxxxxxxxxxxx", user_key: "3xxxxxxxxxxxxxx")
更改之后的
pgyer(api_key: "6xxxxxxxxxxxxxxxxxx", user_key: "3xxxxxxxxxxxxxx", password: "111111", install_type: "2")
增加之后的password測(cè)試人員需要輸入這個(gè)才能下載,比如此處下載密碼為111111
如果剛安裝好環(huán)境豹芯,第一次使用fastlane自動(dòng)打包時(shí)或之后打包出現(xiàn)如下錯(cuò)誤,說明證書的關(guān)聯(lián)沒有找到或者失效驱敲。需要手動(dòng)打包一次觸發(fā)證書的關(guān)聯(lián)(手動(dòng)點(diǎn)擊xcode的Archive打包)铁蹈。
Exit status: 70