fastlane
fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. ?? It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application.
舉個(gè)例子跳芳,在項(xiàng)目根目錄創(chuàng)建包含以下內(nèi)容的Fastfile
文件:
lane :beta do
increment_build_number
build_app
upload_to_testflight
end
lane :release do
capture_screenshots
build_app
upload_to_app_store # Upload the screenshots and the binary to iTunes
slack # Let your team-mates know the new version is live
end
這是兩段fastlane的命令集
然后嘶朱,需要執(zhí)行哪段命令只需要 操作命令 fastlane beta/release
即可讓程序自動(dòng)有序地執(zhí)行所有操作材义。
Getting Started for iOS
Install the latest Xcode command line tools:
xcode-select --install
Install fastlane using
# Using RubyGems
sudo gem install fastlane -NV
# Alternatively using Homebrew
brew cask install fastlane
Navigate to your iOS app and run
fastlane init
fastlane will automatically detect your project, and ask for any missing information.
gz-tankmm:TestForImage tank$ fastlane init
[?] ??
[?] Looking for iOS and Android projects in current directory...
[12:28:02]: Created new folder './fastlane'.
[12:28:02]: Detected an iOS/macOS project in the current directory: 'TestForImage.xcworkspace'
[12:28:02]: -----------------------------
[12:28:02]: --- Welcome to fastlane ?? ---
[12:28:02]: -----------------------------
[12:28:02]: fastlane can help you with all kinds of automation for your mobile app
[12:28:02]: We recommend automating one task first, and then gradually automating more over time
[12:28:02]: What would you like to use fastlane for?
1. ?? Automate screenshots
2. ????? Automate beta distribution to TestFlight
3. ?? Automate App Store distribution
4. ?? Manual setup - manually setup your project to automate your tasks
?
命令執(zhí)行會(huì)生成fastlane文件夾或南,并需要一步步跟著配置fastlane宜咒, 以及根據(jù)需求相應(yīng)地配置該項(xiàng)目設(shè)置。
根據(jù)用戶作出的不同需求選擇梦抢,會(huì)在該文件夾生成不同的配置文件官撼。其中最重要的是fastlane/Fastfile
這個(gè)文件,里面包含了所有需要配置項(xiàng)目的信息劣挫。
比如以上選擇了 1. ?? Automate screenshots
則會(huì)需求手動(dòng)配置項(xiàng)目:
[12:31:40]: Parsing your local Xcode project to find the available schemes and the app identifier
[12:31:40]: $ xcodebuild -showBuildSettings -workspace TestForImage.xcworkspace -scheme TestForImage
? Successfully created SnapshotHelper.swift './fastlane/SnapshotHelper.swift'
? Successfully created new Snapfile at './fastlane/Snapfile'
-------------------------------------------------------
Open your Xcode project and make sure to do the following:
1) Add a new UI Test target to your project
2) Add the ./fastlane/SnapshotHelper.swift to your UI Test target
You can move the file anywhere you want
3) Call `setupSnapshot(app)` when launching your app
let app = XCUIApplication()
setupSnapshot(app)
app.launch()
4) Add `snapshot("0Launch")` to wherever you want to trigger screenshots
5) Add a new Xcode scheme for the newly created UITest target
6) Add a Check to enable the `Shared` box of the newly created scheme
這時(shí)候可以看到fastlane/Fastfile
長(zhǎng)這樣的:
里面包含了截圖并上傳到appstore的相關(guān)命令册养,隨后只需要在項(xiàng)目路徑下執(zhí)行fastlane screenshots
就可以自動(dòng)執(zhí)行這些操作了。
在配置fastlane的過(guò)程中压固,也會(huì)自動(dòng)在項(xiàng)目根目錄下生成Gemfile
以及Gemfile.lock
文件球拦,里面定義了fastlane的版本和依賴,這會(huì)提高使用fastlane的速度帐我,這也是官方推薦的坎炼。
更多的自動(dòng)命令集參考 https://docs.fastlane.tools/actions/
自定義動(dòng)作
除了fastlane官方預(yù)置的動(dòng)作外,更多的是使用自定義的適合自己的動(dòng)作:
這里創(chuàng)建了一個(gè)build_qa
的腳本拦键,使用fastlane build_qa
啟動(dòng)執(zhí)行谣光,進(jìn)行觸發(fā)bitrise build qa .ipa的一系列操作。