官網地址:docs.fastlane.tools/plugins/ava…ios
插件:docs.fastlane.tools/plugins/ava…
命令:docs.fastlane.tools/actions/git
下面咱們就來介紹一下自動打包github
先安裝Ruby環境,參考這篇文章Mac配置Ruby環境和安裝CocoaPodsswift
1.使用Homebrew安裝xcode
sudo gem install fastlane
複製代碼
若是出現以下狀況markdown
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
複製代碼
解決方案:app
sudo gem install -n /usr/local/bin fastlane
複製代碼
sudo gem unstall fastlane
複製代碼
這裏須要看你是經過什麼方式安裝ide
1.經過gem方式安裝oop
sudo gem install fastlane
複製代碼
2.經過Homebrew方式安裝post
brew upgrade fastlane
複製代碼
先找到Fastlane的位置
which fastlane
複製代碼
位置以下:
/usr/local/bin/fastlane
複製代碼
fastlane --version
複製代碼
結果以下:
fastlane installation at path:
/Library/Ruby/Gems/2.6.0/gems/fastlane-2.180.1/bin/fastlane
-----------------------------
[✔] 🚀
fastlane 2.180.1
複製代碼
fastlane init
複製代碼
這裏有4種選擇供選擇,
[✔] 🚀
[✔] Looking for iOS and Android projects in current directory...
[16:59:49]: Created new folder './fastlane'.
[16:59:49]: Detected an iOS/macOS project in the current directory: 'KJTestCategoryDemo.xcworkspace'
[16:59:49]: -----------------------------
[16:59:49]: --- Welcome to fastlane 🚀 ---
[16:59:49]: -----------------------------
[16:59:49]: fastlane can help you with all kinds of automation for your mobile app
[16:59:49]: We recommend automating one task first, and then gradually automating more over time
[16:59:49]: 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
複製代碼
輸入1
[17:00:43]: -------------------------------------------------------
[17:00:43]: --- Setting up fastlane to automate iOS screenshots ---
[17:00:43]: -------------------------------------------------------
[17:00:43]: fastlane uses UI Tests to automate generating localized screenshots of your iOS app
[17:00:43]: fastlane will now create 2 helper files that are needed to get the setup running
[17:00:43]: For more information on how this works and best practices, check out
[17:00:43]: https://docs.fastlane.tools/getting-started/ios/screenshots/
複製代碼
輸入2
[17:00:49]: Parsing your local Xcode project to find the available schemes and the app identifier
[17:00:49]: Resolving Swift Package Manager dependencies...
[17:00:49]: $ xcodebuild -resolvePackageDependencies -workspace KJTestCategoryDemo.xcworkspace -scheme KJTestCategoryDemo
[17:00:50]: ▸ Command line invocation:
[17:00:50]: ▸ /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies -workspace KJTestCategoryDemo.xcworkspace -scheme KJTestCategoryDemo
[17:00:51]: ▸ resolved source packages:
[17:00:51]: $ xcodebuild -showBuildSettings -workspace KJTestCategoryDemo.xcworkspace -scheme KJTestCategoryDemo
✅ 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
More information: https://docs.fastlane.tools/getting-started/ios/screenshots/
[17:00:53]: If you want more details on how to setup automatic screenshots, check out
[17:00:53]: https://docs.fastlane.tools/getting-started/ios/screenshots/#setting-up-snapshot
複製代碼
輸入3,輸入Apple帳號和密碼
[17:02:24]: --------------------------------
[17:02:24]: --- Login with your Apple ID ---
[17:02:24]: --------------------------------
[17:02:24]: To use App Store Connect and Apple Developer Portal features as part of fastlane,
[17:02:24]: we will ask you for your Apple ID username and password
[17:02:24]: This is necessary for certain fastlane features, for example:
[17:02:24]:
[17:02:24]: - Create and manage your provisioning profiles on the Developer Portal
[17:02:24]: - Upload and manage TestFlight and App Store builds on App Store Connect
[17:02:24]: - Manage your App Store Connect app metadata and screenshots
[17:02:24]:
[17:02:24]: Your Apple ID credentials will only be stored in your Keychain, on your local machine
[17:02:24]: For more information, check out
[17:02:24]: https://github.com/fastlane/fastlane/tree/master/credentials_manager
[17:02:24]:
[17:02:24]: Please enter your Apple ID developer credentials
[17:02:24]: Apple ID Username:
複製代碼
這時咱們會發現咱們的目錄下面多了一個下面的文件夾,
fastlane ios tf
複製代碼
缺乏插件,解決方案:
2.1 安裝
bundle install
2.2 安裝插件bundle exec fastlane add_plugin fir
成功以下:
正常發佈流程,
提示缺少發佈證書,
接下來就是等待打包過程,成功以下:
接下來就是上傳到蘋果平臺,這裏會提示你登陸蘋果帳號:
發佈成功界面: 總耗時,12分鐘