fastlane的使用
-
fastlane簡介
Fastlane基于ruby環境自動化工具集,它不是一個工具,它是一系列的工具的集合,基本上涵蓋了打包,簽名,測試,部署,發布,庫管理等等移動開發中涉及到的內容。 同時該套件也支持與 Jenkins 、CocoaPods、xctools 等其他第三方工具的集成。
-
安裝 Xcode command line tools:
xcode-select --install
安裝過會提示已經安裝;
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
-
安裝Fastlane
sudo gem install fastlane
-
fastlane 初始化和使用
cd 打開工程所在目錄,執行fastlane init
出現如下提示:
[圖片上傳失敗...(image-9d0272-1738919747409)]
選擇4 ,手動設置工程文件;然后一路enter
[圖片上傳失敗...(image-3c5e31-1738919747409)]
然后可看到工程目錄下多了幾個文件:
[圖片上傳失敗...(image-4c04d5-1738919747409)]
其中Appfile、Fastfile就是我們需要修改的文件;
- Appfile:App相關的信息,寫以下幾項就可以:
app_identifier("xxxxxxxxx") # The bundle identifier of your app
apple_id("xxxxxxx") # Your Apple email address
team_id("xxxxxxxx") # Developer Portal Team ID
itc_team_id("xxxxx") # App Store Connect Team ID
[圖片上傳失敗...(image-8a0ef6-1738919747409)]
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style> td {white-space:nowrap;border:0.5pt solid #dee0e3;font-size:10pt;font-style:normal;font-weight:normal;vertical-align:middle;word-break:normal;word-wrap:normal;}</style> <byte-sheet-html-origin data-id="" data-version="4" data-is-embed="true" data-grid-line-hidden="false" data-copy-type="col"><colgroup><col width="105"><col width="105"><col width="658"></colgroup>
| 參數 | 作用 | 在哪里使用 |</byte-sheet-html-origin>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style> td {white-space:nowrap;border:0.5pt solid #dee0e3;font-size:10pt;font-style:normal;font-weight:normal;vertical-align:middle;word-break:normal;word-wrap:normal;}</style> <byte-sheet-html-origin data-id="" data-version="4" data-is-embed="true" data-grid-line-hidden="false" data-copy-type="col"><colgroup><col width="105"><col width="105"><col width="659"></colgroup>
| team_id | Developer Portal Team ID(蘋果開發者團隊 ID) | 用于訪問 **Apple Developer Portal(開發者網站 https://developer.apple.com/)**,管理證書、描述文件、App IDs 等 |</byte-sheet-html-origin>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style> td {white-space:nowrap;border:0.5pt solid #dee0e3;font-size:10pt;font-style:normal;font-weight:normal;vertical-align:middle;word-break:normal;word-wrap:normal;}</style> <byte-sheet-html-origin data-id="" data-version="4" data-is-embed="true" data-grid-line-hidden="false" data-copy-type="col"><colgroup><col width="105"><col width="105"><col width="660"></colgroup>
| itc_team_id | App Store Connect Team ID(App Store 團隊 ID) | 用于訪問 **App Store Connect(https://appstoreconnect.apple.com/)**,管理 App 版本、元數據、TestFlight、App Store 提交等 |</byte-sheet-html-origin>
- Fastfile:描述打包相關的配置信息,初始內容如下:
[圖片上傳失敗...(image-7ac7b8-1738919747409)]
一個lane 可理解為就是一個任務,
我們打包發布到蒲公英是一個任務,打包發布到App Store也是一個任務;
lane中可添加多個action,也就是具體的操作,
比如打包方法操作是一個action,
發布蒲公英操作也是一個action;
fastlane打包以及發布到蒲公英
-
在Fastfile文件中填寫(*)
lane :release do
gym(
clean: true, # 是否清空工程
silent: true, # 運行時不顯示詳細日志
#project: "danceRN.xcodeproj",
export_method: 'ad-hoc', # 導出ad-hoc包
output_directory: './fastlane/build', # 生成的 .ipa 文件存放位置
output_name:"danceRN.ipa", # 最終生成的 .ipa 文件名稱
scheme: 'danceRN', # Xcode 里的 Scheme
configuration: 'Release', # Release 版本適用于發布
include_symbols:true, # 包含符號表,用于崩潰分析(生成 .dSYM 文件)
export_xcargs: "-allowProvisioningUpdates", # 允許更新 Provisioning Profile(避免證書/描述文件更新失敗)
)
pgyer(
api_key: "e09a773739c4e94e199bf84612cd311e", # 蒲公英的apikey
update_description: "服務:生產環境;打包:生產包" # 蒲公英的描述
)
end
用到的不多,其他參數還很多具體參看: gym方法及參數配置-http://docs.fastlane.tools/actions/gym/#gym
-
添加蒲公英插件
cd 打開工程所在目錄,執行如下:
fastlane add_plugin pgyer
具體參考:https://www.pgyer.com/doc/view/fastlane
-
終端執行
fastlane release (可理解為就是我們的任務名)
然后剩下的就不用我們管了,它會自動的幫我們處理余下的所有工作;
fastlane打包以及發布到appstore
-
在Fastfile文件中填寫
desc "以 app-store 方式打包并上傳到 iTunes Connect"
lane :appconnect do
puts "自動生成 Provisioning Profiles 文件"
puts "以 app-store 方式打包"
gym(
# 指定打包所使用的輸出方式 (可選: app-store, package, ad-hoc, enterprise, development)
export_method: "app-store",
# 指定項目的 scheme 名稱
scheme: "danceRN",
# 指定輸出的文件夾地址
output_directory: './fastlane/build',
output_name:"danceRN.ipa",
# 指定打包方式 (可選: Release, Debug)
configuration: "Release",
export_xcargs: "-allowProvisioningUpdates"
)
#puts "上傳 ipa 包到 TestFlight"
#pilot(team_name: "Shenzhen Kuai Feike Logistics Co., Ltd.")
puts "上傳 ipa 包到 iTunes Connect"
# 設置apple專用密碼
ENV['FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD'] = "tdqe-pvuj-zowz-ikup"
deliver(
release_notes: { # 更新日志
'en-US' => "Bug fixes and performance improvements.", # 英文
'ar-SA' => "??????? ??????? ???????? ??????.", # 阿拉伯文(沙特阿拉伯)
'hi' => "?? ????? ?? ???????? ??????", # 北印度文(印度)
'de-DE' => "Fehlerbehebungen und Leistungsverbesserungen.", # 德文(德國)
'ru' => "Исправления ошибок и улучшение производительности.", # 俄文(俄羅斯)
'fr-FR' => "Corrections de bugs et améliorations des performances.", # 法文(法國)
'nl-NL' => "Foutoplossingen en prestatieverbeteringen.", # 荷蘭文(荷蘭)
'no' => "Feilrettinger og ytelsesforbedringer.", # 挪威文(挪威)
'pt-BR' => "Corre??es de bugs e melhorias de desempenho.", # 葡萄牙文(巴西)
'ja' => "バグ修正とパフォーマンスの改善。", # 日文(日本)
'sv' => "Felr?ttningar och prestandaf?rb?ttringar.", # 瑞典文(瑞典)
'es-MX' => "Correcciones de errores y mejoras en el rendimiento.", # 西班牙文(墨西哥)
'he' => "?????? ????? ??????? ???????." # 希伯來文(以色列)
},
# 跳過截圖上傳
skip_screenshots: true,
# 跳過元數據上傳
# skip_metadata: true,
# 不跳過元數據上傳, 即 會上傳 App Store Connect 相關的應用元數據(比如應用名稱、描述、關鍵詞、更新日志等)。
skip_metadata: false,
#跳過上傳ipa或pkg到iTunes Connect
skip_binary_upload: false,
# 跳過審核直接上傳
force: true,
# 在上傳所有內容后提交新版本進行審核
submit_for_review: true,
# 一旦應用程序審核通過,該應用會自動發布App Store
automatic_release: false
)
end
注意FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD專用密碼的替換 apple專用密碼可在官網https://account.apple.com/account/manage,安全里找到
參考:
fastlane的具體命令含義等(在里面搜):
-
在package.json中添加如下
"dev": "cd ios && fastlane dev && cd ..",
"release": "cd ios && fastlane release && cd ..",
"appstore": "cd ios && fastlane appconnect && cd ..",
終端執行
yarn dev 打測試包并上傳到蒲公英
yarn release 打生產包并上傳到蒲公英
yarn appstore 打生產包提審到appstore
舉例:
執行yarn appstore,先是打app-store包
[圖片上傳失敗...(image-fd43ad-1738919747409)]
上傳iap:
[圖片上傳失敗...(image-d8b162-1738919747409)]
提交審核:
[圖片上傳失敗...(image-9bb5db-1738919747409)]