Fastlane自動化打包---安裝篇
Fastlane自動化打包---配置篇
Fastlane自動化打包---打包上傳蒲公英篇
參考文檔:
- Fastlane官方文檔
- Github源碼地址
- fastlane感悟
- Fastlane實戰(zhàn)(一):移動開發(fā)自動化之道
- Fastlane實戰(zhàn)(二):Action和Plugin機制
- iOS自動化發(fā)布--Fastlane本地構(gòu)建IPA并分發(fā)
- Fastlane的黑魔法:一鍵打包編譯上傳 AppStore
3. 打包上傳App Store Connect
3.1 先貼上lane這里面講解的都是試驗成功的
desc "打包上傳到 App Store"
lane :do_appstore do
# 自動代碼簽名
#enable_automatic_code_signing
gym(
clean:true,
scheme:"項目名稱", #scheme
configuration: "Release",#環(huán)境
output_directory: "./Ipa",#ipa的存放目錄
output_name: "項目名稱_" + get_version_number_from_plist() + "_" + get_build_number_from_plist() + "_" + Time.new.strftime("%Y-%m-%d %H-%M-%S"),
export_options: {
method: "app-store",
provisioningProfiles: {
"Bundle identifier": "發(fā)布證書"
}
}
)
#upload_to_app_store
# slack(message: "Successfully uploaded a new App Store build")
# deliver(force: false, skip_screenshots: true, skip_metadata: true)
# deliver(force: false)
deliver(
# ipa: "#{OUTPUT_DIRECTORY}" + "/" + "#{IPA_NAME}",
# skip_screenshots: true,
# skip_metadata: true
)
end
3.1.1 fastlane
目錄
- 先分析一下
fastlane
目錄
fastlane目錄
Appfile
這里面是app賬號和項目的team_id 的一些配置項Fastfile
這主要是 腳本編譯、打包和上傳等Deliverfile
、metadata
、screenshots
主要是App Store Connect
中的配置- (1)
metadata
目錄
metadata目錄詳情
注釋:metadata 主要是App Store Connect 中的配置項,宣傳文本、app名稱、關(guān)鍵字、隱私網(wǎng)址、app的logo
(1.1)review_information 文件主要是 App 審核信息 的配置、賬號、備注、聯(lián)系方式
(1.2)trade_representative_contact_information 文件主要是 商務(wù)代表聯(lián)系信息 的配置
- (2)
screenshots
目錄
screenshots目錄注釋:這個文件主要是各個尺寸屏幕的截圖
- 如果沒有這些文件、或者也可以直接把
Deliverfile
、metadata
、screenshots
這三個刪除掉執(zhí)行deliver init
重新從App Store Connect
拉取
$ fastlane deliver init
[?] ??
cat: ./fastlane/Fastfile: No such file or directory
[14:23:24]: Login to App Store Connect (`開發(fā)者賬號`)
[14:23:28]: Login successful
+--------------------------------------+------------------------+
| deliver 2.100.1 Summary |
+--------------------------------------+------------------------+
| run_precheck_before_submit | false |
| screenshots_path | ./fastlane/screenshots |
| metadata_path | ./fastlane/metadata |
| username | `開發(fā)者賬號` |
| app_identifier | `Bundle identifier` |
| edit_live | false |
| platform | ios |
| skip_binary_upload | false |
| use_live_version | false |
| skip_screenshots | false |
| skip_metadata | false |
| skip_app_version_update | false |
| force | false |
| submit_for_review | false |
| reject_if_possible | false |
| automatic_release | false |
| phased_release | false |
| team_id |`team_id` |
| dev_portal_team_id | `dev_portal_team_id` |
| overwrite_screenshots | false |
| precheck_default_rule_level | warn |
| ignore_language_directory_validation | false |
| precheck_include_in_app_purchases | true |
+--------------------------------------+------------------------+
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/description.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/keywords.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/release_notes.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/support_url.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/marketing_url.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/promotional_text.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/name.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/subtitle.txt'
[14:23:31]: Writing to './fastlane/metadata/zh-Hans/privacy_url.txt'
[14:23:31]: Writing to './fastlane/metadata/copyright.txt'
[14:23:31]: Writing to './fastlane/metadata/primary_category.txt'
[14:23:31]: Writing to './fastlane/metadata/secondary_category.txt'
[14:23:31]: Writing to './fastlane/metadata/primary_first_sub_category.txt'
[14:23:31]: Writing to './fastlane/metadata/primary_second_sub_category.txt'
[14:23:31]: Writing to './fastlane/metadata/secondary_first_sub_category.txt'
[14:23:31]: Writing to './fastlane/metadata/secondary_second_sub_category.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/trade_name.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/first_name.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/last_name.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/address_line1.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/address_line2.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/address_line3.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/city_name.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/state.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/country.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/postal_code.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/phone_number.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/email_address.txt'
[14:23:31]: Writing to './fastlane/metadata/trade_representative_contact_information/is_displayed_on_app_store.txt'
[14:23:31]: Writing to './fastlane/metadata/review_information/first_name.txt'
[14:23:31]: Writing to './fastlane/metadata/review_information/last_name.txt'
[14:23:31]: Writing to './fastlane/metadata/review_information/phone_number.txt'
[14:23:31]: Writing to './fastlane/metadata/review_information/email_address.txt'
[14:23:31]: Writing to './fastlane/metadata/review_information/demo_user.txt'
[14:23:31]: Writing to './fastlane/metadata/review_information/demo_password.txt'
[14:23:31]: Writing to './fastlane/metadata/review_information/notes.txt'
[14:23:31]: Successfully created new configuration files.
[14:23:31]: Downloading all existing screenshots...
[14:23:33]: Successfully downloaded all existing screenshots
[14:23:33]: Successfully created new Deliverfile at path './fastlane/Deliverfile'
-
注釋:我發(fā)現(xiàn)證書和描述性文件也被拉取下來了
fastlane目錄
3.1.2 代碼簽名
貼上官方lane證書簽名指南
lane :beta do get_certificates # invokes cert get_provisioning_profile # invokes sigh build_app end
貼上我測試過的
自動簽名打包lane
desc "純打包,指定路徑" lane :do_bale do get_certificates # invokes cert get_provisioning_profile # invokes sigh enable_automatic_code_signing gym( clean:true, #打包前clean項目 export_method: "app-store", #導出方式 scheme:"項目名稱", #scheme configuration: "Release",#環(huán)境 output_directory: "./Ipa",#ipa的存放目錄 output_name: "項目名稱_" + get_version_number_from_plist() + "_" + get_build_number_from_plist() + "_" + Time.new.strftime("%Y-%m-%d %H-%M-%S"), #輸出ipa的文件名為當前的build號和創(chuàng)建的時間 ) end
貼上我測試過的
手動簽名打包lane
desc "純打包,指定路徑" lane :do_bale do gym( clean:true, #打包前clean項目 #export_method: "app-store", #導出方式 scheme:"項目名稱", #scheme configuration: "Release",#環(huán)境 output_directory: "./Ipa",#ipa的存放目錄 output_name: "項目名稱_" + get_version_number_from_plist() + "_" + get_build_number_from_plist() + "_" + Time.new.strftime("%Y-%m-%d %H-%M-%S"), #輸出ipa的文件名為當前的build號和創(chuàng)建的時間 export_options: { method: "ad-hoc", provisioningProfiles: { "Bundle identifier": "發(fā)布證書" } } ) end
注意:
自動打包親測export_method: "app-store"
成功,method: "ad-hoc"
沒有成功
注意:
手動指定簽名export_method: "app-store"
和method: "ad-hoc"
都成功
3.1.3 get_version_number_from_plist
版本號和get_build_number_from_plist
Build號
versioning插件
3.1.4 upload_to_app_store
和deliver
貼上官方lane
lane :release do capture_screenshots # generate new screenshots for the App Store sync_code_signing(type: "appstore") # see code signing guide for more information build_app(scheme: "MyApp") upload_to_app_store # upload your app to App Store Connect slack(message: "Successfully uploaded a new App Store build") end
3.1.5最后執(zhí)行腳本
$ fastlane do_appstore
[?] ??
[15:45:01]: fastlane detected a Gemfile in the current directory
[15:45:01]: however it seems like you don't use `bundle exec`
[15:45:01]: to launch fastlane faster, please use
[15:45:01]:
[15:45:01]: $ bundle exec fastlane do_appstore
[15:45:01]:
[15:45:01]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
+----------------------------+---------+----------------------------------------------+
| Used plugins |
+----------------------------+---------+----------------------------------------------+
| Plugin | Version | Action |
+----------------------------+---------+----------------------------------------------+
| fastlane-plugin-pgyer | 0.2.1 | pgyer |
| fastlane-plugin-fir | 0.3.0 | fir |
| fastlane-plugin-versioning | 0.3.4 | get_version_number_from_git_branch |
| | | get_version_number_from_plist |
| | | get_build_number_from_plist ci_build_number |
| | | increment_version_number_in_plist |
| | | get_app_store_version_number |
| | | get_info_plist_path |
| | | increment_build_number_in_plist |
+----------------------------+---------+----------------------------------------------+
- (1) 上傳配置信息
注釋:如果選擇上傳配置信息、就要確保配置信息無誤,如果有錯誤會有各種各樣的錯誤
證書錯誤
電話和郵箱格式不正確
······· 要確保和手動填寫提交審核時的一樣
如果是測試、要留意
+----------------------------------------------------------------------------+------------------------------------------------------------------------+
[16:11:25]: Making sure the latest version on App Store Connect matches '2.2.2' from the ipa file...
[16:11:27]: '2.2.2' is the latest version on App Store Connect
[16:11:31]: Loading './fastlane/metadata/zh-Hans/description.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/keywords.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/release_notes.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/support_url.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/marketing_url.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/promotional_text.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/name.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/subtitle.txt'...
[16:11:31]: Loading './fastlane/metadata/zh-Hans/privacy_url.txt'...
[16:11:31]: Loading './fastlane/metadata/copyright.txt'...
[16:11:31]: Loading './fastlane/metadata/primary_category.txt'...
[16:11:31]: Loading './fastlane/metadata/secondary_category.txt'...
[16:11:31]: Loading './fastlane/metadata/primary_first_sub_category.txt'...
[16:11:31]: Loading './fastlane/metadata/primary_second_sub_category.txt'...
[16:11:31]: Loading './fastlane/metadata/secondary_first_sub_category.txt'...
[16:11:31]: Loading './fastlane/metadata/secondary_second_sub_category.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/trade_name.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/first_name.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/last_name.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/address_line1.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/address_line2.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/address_line3.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/city_name.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/state.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/country.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/postal_code.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/phone_number.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/email_address.txt'...
[16:11:31]: Loading './fastlane/metadata/trade_representative_contact_information/is_displayed_on_app_store.txt'...
[16:11:31]: Loading './fastlane/metadata/review_information/first_name.txt'...
[16:11:31]: Loading './fastlane/metadata/review_information/last_name.txt'...
[16:11:31]: Loading './fastlane/metadata/review_information/phone_number.txt'...
[16:11:31]: Loading './fastlane/metadata/review_information/email_address.txt'...
[16:11:31]: Loading './fastlane/metadata/review_information/demo_user.txt'...
[16:11:31]: Loading './fastlane/metadata/review_information/demo_password.txt'...
[16:11:31]: Loading './fastlane/metadata/review_information/notes.txt'...
[?] Activating language zh-Hans...
[?] Uploading metadata to App Store Connect
[16:11:44]: Successfully uploaded set of metadata to App Store Connect
[16:11:45]: Starting with the upload of screenshots...
[?] Activating language zh-Hans...
[16:11:48]: Uploading 11 screenshots for language zh-Hans
[16:11:48]: Uploading './fastlane/screenshots/screenshots/zh-Hans/1_iphone4_1.ftl_11d731b90df1c3645f919d2f51fe37a8_e60f7266d2656cfa5e64d22c1567285d.png'...
[16:11:51]: Uploading './fastlane/screenshots/screenshots/zh-Hans/1_iphone6Plus_1.ftl_99bb9bd51f334680d95e3b1b8fc0ef04_076e191d45fe34764f4e6ed5704aee81.png'...
[16:11:56]: Uploading './fastlane/screenshots/screenshots/zh-Hans/1_iphone6_1.ftl_4e9ce811abd345622b10489f845c3b29_f501e81c3e63f21112e6d32ca4ed9ac4.png'...
[16:11:59]: Uploading './fastlane/screenshots/screenshots/zh-Hans/2_iphone4_2.ftl_facee086666c5c79b9441235b0c94778_89c9e2b1813d8bfe5ae9ceb976e1a1a0.png'...
[16:12:03]: Uploading './fastlane/screenshots/screenshots/zh-Hans/2_iphone6Plus_2.ftl_ae5048f1552f8600f6f44ee7269d581a_10b76cd5ff6943ee458b1696864df2d4.png'...
[16:12:08]: Uploading './fastlane/screenshots/screenshots/zh-Hans/2_iphone6_2.ftl_08074a0506500331aeebda7288539c16_02168c78e7f37da3b1bda572ad42d7ef.png'...
[16:12:13]: Uploading './fastlane/screenshots/screenshots/zh-Hans/3_iphone4_3.ftl_7ab14d6392ed2e0d00edcc255f146cf9_a1da622644dae3918463434422b93e4f.png'...
[16:12:16]: Uploading './fastlane/screenshots/screenshots/zh-Hans/3_iphone6Plus_3.ftl_df9239345fc94a1ee5119d9930742e6a_b50dd8d0c3d4d99db41ab78e7125f32c.png'...
[16:12:21]: Uploading './fastlane/screenshots/screenshots/zh-Hans/3_iphone6_3.ftl_7cfd678b4285f23a03810d47d537181c_6f7c2fd5ee0f1c7dd1852e54039c7093.png'...
[16:12:24]: Uploading './fastlane/screenshots/screenshots/zh-Hans/4_iphone4_4.ftl_bf910dacc0a8aa47ff661d34ea4e2d65_23da69b031d8eeb28bdb5bfdaeec976c.png'...
[16:12:26]: Uploading './fastlane/screenshots/screenshots/zh-Hans/4_iphone6_4.ftl_d0c67f5b2aa28012a92e9600d616f926_bdf7a019e3f5da3d0aa9d5c80c4b43a2.png'...
[?] Saving changes
[16:12:36]: Successfully uploaded screenshots to App Store Connect
[16:12:39]: Uploading app icon...
[16:12:49]: Uploading binary to App Store Connect
[16:12:50]: Going to upload updated app to App Store Connect
[16:12:50]: This might take a few minutes. Please don't interrupt the script.
[16:16:31]: iTunes Transporter successfully finished its job
[16:16:31]: ------------------------------------------------------------------------------------------------------------------
[16:16:31]: --- Successfully uploaded package to App Store Connect. It might take a few minutes until it's visible online. ---
[16:16:31]: ------------------------------------------------------------------------------------------------------------------
[16:16:31]: Finished the upload to App Store Connect
+------+-------------------------------+-------------+
| fastlane summary |
+------+-------------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | get_version_number_from_plist | 1 |
| 3 | get_build_number_from_plist | 1 |
| 4 | gym | 41 |
| 5 | deliver | 311 |
+------+-------------------------------+-------------+
[16:16:31]: fastlane.tools just saved you 6 minutes! ??
- (1.1)
補充
Deliverfile
也可以配置信息,而且優(yōu)先級比較高,如果在這里配置了,上傳的時候就會優(yōu)先獲取Deliverfile
文件中的配置- 貼上我的
Deliverfile
文件中的配置,有部分注釋掉了force(true); automatic_release(true); run_precheck_before_submit(false); precheck_include_in_app_purchases(false); # skip_metadata(true); metadata_path("./fastlane/metadata"); # skip_screenshots(true); screenshots_path("./fastlane/screenshots/screenshots"); # languages(['zh-Hans']); # release_notes({ # 'default' => "Shiny and new", # }) # promotional_text( # "default" => "xxxx" # ) # App 審核信息 # app_review_information( # first_name: "first_name", # last_name: "last_name", # phone_number: "+8615658820987", # email_address: "jimmylot@126.com", # demo_user: "+8615658820987", # demo_password: "9527", # notes: "備注信息" # ) # trade_representative_contact_information( # first_name: "first_name", # last_name: "last_name", # address_line1: "address_line1", # address_line2: "address_line2", # address_line3: "address_line3", # city_name: "city_name", # state: "state", # country: "country", # postal_code: "postal_code", # phone_number: "+8615658820987",#位數(shù)必須正確 # email_address: "jimmylot@126.com", # is_displayed_on_app_store:"false", # trade_name:"XXXXXXXX Financial Information Service Co., Ltd." # ) # # 如果選擇提交審核,請認真對照以下參數(shù)選項,根據(jù)自家App實際情況配置,如果配置錯誤,將不能提交成功 submission_information({ export_compliance_available_on_french_store: false, export_compliance_contains_proprietary_cryptography: false, export_compliance_contains_third_party_cryptography: false, export_compliance_is_exempt: false, export_compliance_uses_encryption: false, export_compliance_app_type: nil, export_compliance_encryption_updated: false, export_compliance_compliance_required: false, export_compliance_platform: "ios", content_rights_contains_third_party_content: false, content_rights_has_rights: false, add_id_info_limits_tracking: true, add_id_info_serves_ads: true, add_id_info_tracks_action: false, add_id_info_tracks_install: false, add_id_info_uses_idfa: true });
- (2) 不上傳配置信息
如果選擇不上傳 就跳過配置信息,這樣就只上傳一個 ipa 的包
skip_screenshots: true,
skip_metadata: true
[16:06:37]: Making sure the latest version on App Store Connect matches '2.2.2' from the ipa file...
[16:06:40]: '2.2.2' is the latest version on App Store Connect
[16:06:44]: Uploading binary to App Store Connect
[16:06:44]: Going to upload updated app to App Store Connect
[16:06:44]: This might take a few minutes. Please don't interrupt the script.
[16:10:12]: iTunes Transporter successfully finished its job
[16:10:12]: ------------------------------------------------------------------------------------------------------------------
[16:10:12]: --- Successfully uploaded package to App Store Connect. It might take a few minutes until it's visible online. ---
[16:10:12]: ------------------------------------------------------------------------------------------------------------------
[16:10:12]: Finished the upload to App Store Connect
+------+-------------------------------+-------------+
| fastlane summary |
+------+-------------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | get_version_number_from_plist | 1 |
| 3 | get_build_number_from_plist | 1 |
| 4 | gym | 39 |
| 5 | deliver | 221 |
+------+-------------------------------+-------------+
[16:10:12]: fastlane.tools finished successfully ??