Fastlane 是一款爲 iOS 和 Android 開發者提供的自動化構建工具,它能夠幫助開發者將 App 打包、簽名、測試、發佈、信息整理、提交 App Store 等工做完整的鏈接起來,實現徹底自動化的工做流,若是使用得當,能夠顯著的提升開發者的開發效率。ios
之前咱們都是打包完ipa,再手動上傳到蒲公英,可是利用Fastlane,能夠手動上傳到蒲公英,提升效率。本人親自對比過,在相同機械硬盤的狀況下,自動打包比手動打包快了1分10秒!別小看這個一分多秒,效率就是金錢!api
一、在終端中,輸入如下命令,便可安裝蒲公英的 fastlane 插件。 fastlane add_plugin pgyer
xcode
二、稍等幾秒鐘,若是出現相似下面的信息,就說明安裝成功了: bash
一、在使用 Fastlane 以前,咱們首先須要在項目中初始化 Fastlane。首先進入 App 的開發目錄,執行如下命令來初始化 Fastlane: fastlane init
app
二、執行上述命令後,Fastlane 會自動在 App 目錄中生成 fastlane 目錄,其中就會有 Fastlane 的配置文件 fastlane/Fastfile,能夠用文本方式打開Fastfile,修改以下:ide
default_platform(:ios)
platform :ios do
desc "Description of what the lane does"
lane :beta do
# add actions here: https://docs.fastlane.tools/actions
#build_app(export_method: "ad-hoc")
gym(export_method: "ad-hoc")
pgyer(api_key: "b0ea2xxxxxxx94afdxxx55exxxx132", user_key: "f9x4xxxxxxxxxxxxxxf0a9cx75xb")
end
end
複製代碼
注意: 以上的
api_key
和user_key
,請開發者在本身帳號下的 應用管理 - App概述 - API 中能夠找到,並替換到以上相應的位置。 在Xcode 8.3
和Xcode 8.3
之後的版本中,對於build_app
的export_method
的值,須要根據開發者的打包類型進行設置,可選的值有:app-store
、ad-hoc
、development
、enterprise
。對於 Xcode 8.3 如下的版本,則不須要設置export_method
。工具
一、通過以上配置後,就可使用 Fastlane 來打包 App,並自動上傳到蒲公英了。在終端下,定位到項目所在目錄,輸入如下命令便可: fastlane beta
測試
二、成功會見到以下信息 ui
您也能夠設置 App 上傳到蒲公英時,設置密碼:spa
lane :beta do
build_app(export_method: "ad-hoc")
pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", password: "123456", install_type: "2")
end
複製代碼
設置一個版本更新時的描述信息:
lane :beta do
build_app(export_method: "ad-hoc")
pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", update_description: "update by fastlane")
end
複製代碼
一、提示no found scheme
這是讓你勾選工程的
Scheme
,步驟就是打開你的xcode
,點擊Manage Schemes
,在一堆三方庫中找到你的項目Scheme
,在後面的多選框中進行勾選,而後rm -rf fastlane
文件夾,從新fastlane init
一下就不會報錯了。
二、提示locate not found xcode
相似這樣在mac本地找不到xcode的錯誤
使用
sudo xcode-select -switch /Applications/Xcode.app/
參考:
一、https://baijiahao.baidu.com/s?id=1594756143908261537&wfr=spider&for=pc
二、https://www.pgyer.com/doc/view/fastlane