fastlane是一個通過簡單命令來完成諸如截圖、獲取證書、編譯、導(dǎo)出安裝包、提交iTunesConnect等一系列操作的工具,它同時支持iOS和Android。
你能夠通過簡單的方式配置流程進(jìn)行的順序,并通過非常簡單的命令執(zhí)行其中的一個流程。當(dāng)然它的簡單并不代表功能也簡陋,有開源社區(qū)的支持,更新迅速且有很多功能能夠滿足你的需求。
一、環(huán)境配置
fastlane使用的是ruby環(huán)境且對ruby有版本要求(官網(wǎng)要求是ruby2.0以上),所以如果需要的話更新一波ruby,然后通過homebrew安裝fastlane(或者通過gem安裝,看心情??)
檢查是否安裝ruby并查看ruby版本號
ruby -v
//我的已經(jīng)安裝ruby環(huán)境
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
如果沒有ruby環(huán)境或者ruby環(huán)境低于2.0版本
brew install ruby
然后檢查 Xcode 命令行工具
xcode-select --install
如果報錯誤:
command line tools are already installed, use "Software Update" to install updates.
代表已經(jīng)安裝,否則會開始安裝。
安裝fastlane
sudo gem install fastlane
二、使用fastlane
新建iOS項目并cd
到項目中,然后執(zhí)行:
//cd到工程中,然后執(zhí)行
fastlane init
[18:05:57]: What would you like to use fastlane for?
- ?? Automate screenshots
- ????? Automate beta distribution to TestFlight
- ?? Automate App Store distribution
- ?? Manual setup - manually setup your project to automate your tasks
1 自動截圖
2 打包測試
3 打包上傳到appStore
4 先什么都不干,后面手動配置
我們要上傳AppStore選擇3,然后會讓輸入開發(fā)者賬號和密碼,還可能彈出來一個6位驗證碼,記住這個驗證碼并輸入回車
需要用戶名和密碼:
[18:07:34]: Please enter your Apple ID developer credentials
[18:07:34]: Apple ID Username:
因為我們的開發(fā)這賬號有公司賬號和企業(yè)賬號,而且用的同一個郵箱,所以需要選擇一下:
Multiple teams found on the Developer Portal, please enter the number of the team you want to use:
- xxxxx "IvyGate International Education Technology Co. Ltd" (In-House)
- xxxxx "IvyGate International Education Technology Co. Ltd" (Company/Organization)
1是企業(yè)賬號,內(nèi)部分發(fā)用的299??哪個
2是公司賬號
然后一路輸入 y 或者回車......
如果bundle update
卡住無響應(yīng)那么很有可能是因為被墻了,首先在終端檢查ruby源
gem source
//可以看到自己的信息,我的已經(jīng)替換為gems.ruby-china了
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
如果不是https://gems.ruby-china.com/那么替換一下
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
然后打開工程中的Gemfile
文件
source "https://rubygems.org"
替換為
source "https://gems-china.org"http://taobao的已經(jīng)停止維護(hù)了,國內(nèi)就用這個
然后刪除fastlane
文件夾,打開終端,cd
到工程中,再次執(zhí)行
fastlane init
執(zhí)行完畢之后分別進(jìn)入developer和itunesconnect去看一下appid和app都被新建好了
三、打包提交到AppStore
終端執(zhí)行
fastlane release
有可能報錯
[14:12:17]: Unsupported directory name(s) for screenshots/metadata in './fastlane/screenshots': screenshots
Valid directory names are: ["da", "de-DE", "el", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR", "id", "it", "ja", "ko", "ms", "nl-NL", "no", "pt-BR", "pt-PT", "ru", "sv", "th", "tr", "vi", "zh-Hans", "zh-Hant", "appleTV", "iMessage", "default"]Enable 'ignore_language_directory_validation' to prevent this validation from happening
+------+---------------------+-------------+
| fastlane summary |
+------+---------------------+-------------+
| Step | Action | Time (in s) |
+------+---------------------+-------------+
| 1 | default_platform | 0 |
| 2 | build_app | 52 |
| ?? | upload_to_app_store | 84 |
+------+---------------------+-------------+[14:12:17]: fastlane finished with errors
[!] Unsupported directory name(s) for screenshots/metadata in './fastlane/screenshots': screenshots
Valid directory names are: ["da", "de-DE", "el", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR", "id", "it", "ja", "ko", "ms", "nl-NL", "no", "pt-BR", "pt-PT", "ru", "sv", "th", "tr", "vi", "zh-Hans", "zh-Hant", "appleTV", "iMessage", "default"]Enable 'ignore_language_directory_validation' to prevent this validation from happening
看意思是需要忽略語言文件檢查,打開工程->fastlane文件夾->Fastfile
upload_to_app_store
改為
upload_to_app_store(
ignore_language_directory_validation: true
)
如圖:
再次執(zhí)行
fastlane release
中間可能打開瀏覽器然后蹦出來一個網(wǎng)頁告訴你No Screenshots Found沒有截圖啥的,先不用管以后再完善,點擊y過去
進(jìn)入itunesconnect查看app
提交成功了!!!
參考地址:
文檔地址:https://docs.fastlane.tools/actions/appstore/
http://devhy.com/2018/01/23/26-fastlane-usage/
https://gems.ruby-china.com
http://www.lxweimin.com/p/192c09cc8e27