Fastlane自动化打包---安装篇
Fastlane自动化打包---配置篇
Fastlane自动化打包---打包上传蒲公英篇
参考文档:
- Fastlane官方文档
- Github源码地址
- fastlane感悟
- Fastlane实战(一):移动开发自动化之道
- Fastlane实战(二):Action和Plugin机制
- iOS自动化发布--Fastlane本地构建IPA并分发
- 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",#环境
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": "发布证书"
}
}
)
#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名称、关键字、隐私网址、app的logo
(1.1)review_information 文件主要是 App 审核信息 的配置、账号、备注、联系方式
(1.2)trade_representative_contact_information 文件主要是 商务代表联系信息 的配置
- (2)
screenshots
目录
screenshots目录注释:这个文件主要是各个尺寸屏幕的截图
- 如果没有这些文件、或者也可以直接把
Deliverfile
、metadata
、screenshots
这三个删除掉执行deliver init
重新从App Store Connect
拉取
$ fastlane deliver init
[✔] 🚀
cat: ./fastlane/Fastfile: No such file or directory
[14:23:24]: Login to App Store Connect (`开发者账号`)
[14:23:28]: Login successful
+--------------------------------------+------------------------+
| deliver 2.100.1 Summary |
+--------------------------------------+------------------------+
| run_precheck_before_submit | false |
| screenshots_path | ./fastlane/screenshots |
| metadata_path | ./fastlane/metadata |
| username | `开发者账号` |
| 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'
-
注释:我发现证书和描述性文件也被拉取下来了
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",#环境 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号和创建的时间 ) end
贴上我测试过的
手动签名打包lane
desc "纯打包,指定路径" lane :do_bale do gym( clean:true, #打包前clean项目 #export_method: "app-store", #导出方式 scheme:"项目名称", #scheme configuration: "Release",#环境 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号和创建的时间 export_options: { method: "ad-hoc", provisioningProfiles: { "Bundle identifier": "发布证书" } } ) 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最后执行脚本
$ 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
也可以配置信息,而且优先级比较高,如果在这里配置了,上传的时候就会优先获取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",#位数必须正确 # email_address: "jimmylot@126.com", # is_displayed_on_app_store:"false", # trade_name:"XXXXXXXX Financial Information Service Co., Ltd." # ) # # 如果选择提交审核,请认真对照以下参数选项,根据自家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 🎉