前言
每位iOS開發(fā)工程師都不可避免項目打包的時候,有時候繁瑣的打包即費事又費力仓技,尤其是在大量測試下更是不可避免。這時有了許多的分布平臺和快捷打包工具就大大提高了我們的效率俗他。
蒲公英
蒲公英是國內(nèi)領(lǐng)先的應用內(nèi)測分發(fā)平臺脖捻,我們可以打包應用到這個平臺,進行分布式測試兆衅,而且該平臺支持Jenkins和fastlane郭变。
fastlane
fastlane是使用Ruby語言寫的,支持iOS和安卓的打包涯保、分發(fā)平臺、上傳應用到商店的工具周伦。
fastlane安裝過程
以下過程都在Mac終端上進行
1.建議更新gem?
sudo gem update --system
需要輸入用戶密碼
2.檢查gem源
gem sources
結(jié)果應為
*** CURRENT SOURCES ***
https://gems.ruby-china.org/
如果是夕春,忽略2.1和2.2步驟
2.1如果不是,移除你的源
sources --remove https://rubygems.org/
https://rubygems.org/指的gem sources顯示的源
2.2添加國內(nèi)的源
gem sources -a https://gems.ruby-china.org/
3.安裝Xcode命令行工具
xcode-select --install
如果提示以下专挪,就是安裝過了及志,無需重新安裝
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
4.安裝fastlane
sudo gem install -n /usr/local/bin fastlane
5.安裝完成后可檢測下fastlane版本
fastlane --version
我的版本是2.66.2
/Library/Ruby/Gems/2.3.0/gems/fastlane-2.66.2/bin/fastlane
-----------------------------
fastlane 2.66.2
到現(xiàn)在,我們安裝fastlane的到此告一段落了寨腔。
蒲公英使用
注冊過程就不多說啦
點擊我的應用 -> ?添加空白應用 -> 填上應用名稱和包名 -> 添加應用
成功后點擊API速侈,記下API Key 和?User Key 之后會用到的
fastlane 使用
1.終端cd到項目根目錄,這里我推薦一個小工具Go2Shell迫卢。 點擊它打開終端直達所在目錄:
2.初始化fastlane
fastlane init
走的過程會提示你輸入項目開發(fā)者的AppleID和密碼
Your Apple ID (e.g. fastlane@krausefx.com):
確認項目信息倚搬,有誤按n手動修改
+----------------+--------------------------------------+
| ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Detected Values ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
+----------------+--------------------------------------+
| Apple ID ? ? ? ? ? ?| xxxxx@xxxxx.com ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |?
| App Name ? ? ? | FastlaneDemo ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?|
| App Identifier ?| com.xxxxxx.FastlaneDemo ? ? ? ? ? ? ? ? ? ? ? |
| Workspace ? ? ?| /Users/xxxxxxx/Desktop/FastlaneDemo |
| ? ? ? ? ? ? ? ? ? ? ? ? ?| /FastlaneDemo.xcworkspace ? ? ? ? ? ? ? ? ? ?|
+----------------+--------------------------------------+
這一步是上架App Store用的,可以上信息和效果圖那些乾蛤,我這邊填了n
[14:26:33]: Do you want to setup 'deliver', which is used to upload appscreenshots, app metadata and app updates to the App Store? This requires the app tobe in the App Store already (y/n)
成功之后項目多了個fastlane文件夾
3.配置Fastfile
打開fastlane/Fastfile每界,找到?lane :beta do … ?end,內(nèi)容改為
lane :beta do
????#scheme選擇方案
????gym(scheme: "FastlaneDemo”,
????#output_name 打包的ipa的名字
????output_name: "APPName_AD”,
????#export_method 打包模式
? ? export_method: "ad-hoc”,
????#分別是app-store、ad-hoc家卖、development眨层、enterprise
????????export_options: {
????????provisioningProfiles: {
????????????#"bundle id" => "項目描述文件"
????????????"com.xxxx.FastlaneDemo" => "FastlaneDemoAD"
????????????}
????????})
????#api_key和user_key就是之前蒲公英保存的
????pgyer(api_key: "b9cbebxxxxxxxxxxxxxxxxxxx7de3dd6", user_key: "b9cbebxxxxxxxxxxxxxxxxxxx7de3dd6")?
end
4.添加蒲公英fastlane插件,cd到項目根目錄
fastlane add_plugin pgyer
5.如果項目有pod的上荡,在線根目錄Gemfile文件加上
gem 'cocoapods'
然后終端cd跟目錄操作
gym init
6.開始分發(fā)到蒲公英
bundle exec fastlane beta
7.成功提示
fastlane.tools just saved you 6 minutes! ??
這時趴樱,可以去蒲公英看看你的應用了,以后分發(fā)只需終端根目錄執(zhí)行bundle exec fastlane beta即可酪捡。
注意事項
如果gym 和 bundler版本過舊叁征,可以試試更新一下。
sudo gem install -n /usr/local/bin gym?
sudo gem install -n /usr/local/bin?bundler?
如果沒有開發(fā)者私鑰也會失敗逛薇,需添加私鑰
打包失敗時先試試用xcode打包有沒有問題航揉,在排除證書問題总棵。
Ad-Hoc證書需自己在developer.apple.com上手動生成航瞭。
喜歡的點記得小心心哦~