fastlane運(yùn)行所需要的環(huán)境:
- OS X 10.9以上
- Ruby 2.0 以上
- Xcode
- 擁有一個(gè)開發(fā)者賬號(hào)
因?yàn)閒astlane其實(shí)是一個(gè)Ruby腳本的集合,你必須安裝正確的Ruby版本∑沼撸可用一下命令確認(rèn)
安裝
1、ruby -v
查看ruby版本
2卷要、然后檢查Xcode命令行工具(CLT)是否安裝清女。在終端中輸入命令:
xcode-select --install
如果已經(jīng)安裝玩徊,則會(huì)報(bào)一下錯(cuò)誤
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
如果沒安裝,終端會(huì)開始安裝CLT琼了。
3逻锐、通過(guò)rubygem安裝fastlane
sudo gem install fastlane -v 2.57.2 --verbose
初始化
打開終端,cd到你的工程目錄雕薪,然后執(zhí)行fastlane init
運(yùn)行結(jié)果如下
fastlane init
[15:35:29]: Seems like launching fastlane takes a while - please run
[15:35:29]:
[15:35:29]: $ [sudo] gem cleanup
[15:35:29]:
[15:35:29]: to uninstall outdated gems and make fastlane launch faster
[15:35:29]: Alternatively it's recommended to start using a Gemfile to lock your dependencies
[15:35:29]: To get started with a Gemfile, run
[15:35:29]:
[15:35:29]: $ bundle init
[15:35:29]: $ echo 'gem "fastlane"' >> Gemfile
[15:35:29]: $ bundle install
[15:35:29]:
[15:35:29]: After creating the Gemfile and Gemfile.lock, commit those files into version control
[15:35:29]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[15:35:32]: Detected iOS/Mac project in current directory...
[15:35:32]: This setup will help you get up and running in no time.
[15:35:32]: fastlane will check what tools you're already using and set up
[15:35:32]: the tool automatically for you. Have fun!
[15:35:32]: Created new folder './fastlane'.
[15:35:32]: $ xcodebuild -list -project ./JenkinsDemo.xcodeproj
2017-12-07 15:35:33.629 xcodebuild[39937:3765993] [MT] PluginLoading: Required plug-in compatibility UUID DF11C142-1584-4A99-87AC-1925D5F5652A for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/FuzzyAutocomplete.xcplugin' not present in DVTPlugInCompatibilityUUIDs
[15:35:34]: $ xcodebuild -showBuildSettings -scheme JenkinsDemo -project ./JenkinsDemo.xcodeproj
2017-12-07 15:35:34.373 xcodebuild[39940:3766165] [MT] PluginLoading: Required plug-in compatibility UUID DF11C142-1584-4A99-87AC-1925D5F5652A for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/FuzzyAutocomplete.xcplugin' not present in DVTPlugInCompatibilityUUIDs
[15:35:35]: Your Apple ID (e.g. fastlane@krausefx.com): 這里是你的Apple ID
[15:35:49]: Verifying that app is available on the Apple Developer Portal and iTunes Connect...
[15:35:49]: Starting login with user '這里是你的Apple ID'
+----------------+--------------------------------------+
| Detected Values |
+----------------+--------------------------------------+
| Apple ID | 這里是你的Apple ID |
| App Name | JenkinsDemo |
| App Identifier | com.jenkin.Debug |
| Project | /Users/xyj/Desktop/test/JenkinsDemo |
| | .xcodeproj |
+----------------+--------------------------------------+
[15:36:00]: Please confirm the above values (y/n)
y
[15:36:11]: Created new file './fastlane/Appfile'. Edit it to manage your preferred app metadata information.
[15:36:11]: Loading up 'deliver', this might take a few seconds
[15:36:11]: Login to iTunes Connect (it_ios@ixinyongjia.com)
[15:36:14]: Login successful
+--------------------------------------+------------------------+
| deliver 2.68.2 Summary |
+--------------------------------------+------------------------+
| run_precheck_before_submit | false |
| screenshots_path | ./fastlane/screenshots |
| metadata_path | ./fastlane/metadata |
| username | 這里是你的Apple ID |
| app_identifier | com.jenkin.Debug |
| edit_live | false |
| platform | ios |
| skip_binary_upload | false |
| skip_screenshots | false |
| skip_metadata | false |
| skip_app_version_update | false |
| force | false |
| submit_for_review | false |
| automatic_release | false |
| dev_portal_team_id | 99WG99HF75 |
| overwrite_screenshots | false |
| precheck_default_rule_level | warn |
| ignore_language_directory_validatio | false |
| n | |
| precheck_include_in_app_purchases | true |
+--------------------------------------+------------------------+
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/description.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/keywords.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/release_notes.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/support_url.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/marketing_url.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/promotional_text.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/name.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/subtitle.txt'
[15:36:17]: Writing to './fastlane/metadata/zh-Hans/privacy_url.txt'
[15:36:17]: Writing to './fastlane/metadata/copyright.txt'
[15:36:17]: Writing to './fastlane/metadata/primary_category.txt'
[15:36:17]: Writing to './fastlane/metadata/secondary_category.txt'
[15:36:17]: Writing to './fastlane/metadata/primary_first_sub_category.txt'
[15:36:17]: Writing to './fastlane/metadata/primary_second_sub_category.txt'
[15:36:17]: Writing to './fastlane/metadata/secondary_first_sub_category.txt'
[15:36:17]: Writing to './fastlane/metadata/secondary_second_sub_category.txt'
[15:36:17]: Writing to './fastlane/metadata/trade_representative_contact_information/trade_name.txt'
[15:36:17]: Writing to './fastlane/metadata/trade_representative_contact_information/address_line1.txt'
[15:36:17]: Writing to './fastlane/metadata/trade_representative_contact_information/city_name.txt'
[15:36:17]: Writing to './fastlane/metadata/trade_representative_contact_information/country.txt'
[15:36:17]: Writing to './fastlane/metadata/trade_representative_contact_information/postal_code.txt'
[15:36:17]: Writing to './fastlane/metadata/trade_representative_contact_information/is_displayed_on_app_store.txt'
[15:36:17]: Writing to './fastlane/metadata/review_information/first_name.txt'
[15:36:17]: Writing to './fastlane/metadata/review_information/last_name.txt'
[15:36:17]: Writing to './fastlane/metadata/review_information/phone_number.txt'
[15:36:17]: Writing to './fastlane/metadata/review_information/email_address.txt'
[15:36:17]: Writing to './fastlane/metadata/review_information/demo_user.txt'
[15:36:17]: Writing to './fastlane/metadata/review_information/demo_password.txt'
[15:36:17]: Writing to './fastlane/metadata/review_information/notes.txt'
[15:36:17]: Successfully created new configuration files.
[15:36:17]: Downloading all existing screenshots...
[15:36:19]: Successfully downloaded all existing screenshots
[15:36:19]: Successfully created new Deliverfile at path './fastlane/Deliverfile'
[15:36:19]: 'snapshot' not enabled.
[15:36:19]: 'cocoapods' not enabled.
[15:36:19]: 'carthage' not enabled.
[15:36:19]: Created new file './fastlane/Fastfile'. Edit it to manage your own deployment lanes.
[15:36:19]: fastlane will collect the number of errors for each action to detect integration issues
[15:36:19]: No sensitive/private information will be uploaded
[15:36:19]: Learn more at https://github.com/fastlane/fastlane#metrics
[15:36:19]: Successfully finished setting up fastlane
上述過(guò)程可能要輸密碼昧诱,將Apple ID的密碼正確輸入就可以了。
初始化完成之后所袁,工程目錄下就多了個(gè)fastlane文件夾盏档,內(nèi)容如下
這里肯定會(huì)被創(chuàng)建的是Appfile和Fastfile。如果Deliverfile燥爷,screenshots和metadata目錄沒被創(chuàng)建蜈亩,可以運(yùn)行deliver init來(lái)創(chuàng)建。
Appfile :用來(lái)存儲(chǔ)一些公共信息前翎,比如
app_identifier
稚配、apple_id
、team_id
港华、itc_team_id
等道川。Fastfile:用來(lái)定義所有的lane任務(wù)
一開始的內(nèi)容如下:
# Customize this file, documentation can be found here:
# https://docs.fastlane.tools/actions/
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# If you want to automatically update fastlane if a new version is available:
# 自動(dòng)更新fastlane
# update_fastlane
# This is the minimum version number required.
# Update this, if you use features of a newer version
# 需要的fastlane的最小版本,在每次執(zhí)行之后會(huì)檢查是否有新版本立宜,如果有會(huì)在最后末尾追加新版本提醒
fastlane_version "2.68.2"
# 默認(rèn)使用平臺(tái)是ios愤惰,也就是說(shuō)可以定義多個(gè)平臺(tái)
default_platform :ios
# 執(zhí)行所有的lane語(yǔ)句之前要做的事情,
platform :ios do
before_all do
# 自定義變量
# ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
# 是否使用cocoapods構(gòu)建項(xiàng)目
# cocoapods
# carthage
end
# 跑一遍測(cè)試
desc "Runs all the tests"
lane :test do
run_tests
end
# 提交一個(gè)新的beta版本到 Apple TestFlight
desc "Submit a new Beta Build to Apple TestFlight"
desc "This will also make sure the profile is up to date"
lane :beta do
# match(type: "appstore") # more information: https://codesigning.guide
build_app(scheme: "JenkinsDemo") # more options available
upload_to_testflight
# sh "your_script.sh"
# You can also use other beta testing services here (run `fastlane actions`)
end
# 部署一個(gè)新版本到App store
desc "Deploy a new version to the App Store"
lane :release do
# sync_code_signing(type: "appstore")
capture_screenshots
build_app(scheme: "JenkinsDemo") # Build your app - more options available
upload_to_app_store(force: true)
# frame_screenshots
end
# 你也可以定義自己的lane
# You can define as many lanes as you want
# 執(zhí)行l(wèi)ane之后的回調(diào)
after_all do |lane|
# This block is called, only if the executed lane was successful
# slack(
# message: "Successfully deployed new App Update."
# )
end
# 流程異常赘理,結(jié)束流程并輸出錯(cuò)誤信息
error do |lane, exception|
# slack(
# message: exception.message,
# success: false
# )
end
end
# More information about multiple platforms in fastlane: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
# All available actions: https://docs.fastlane.tools/actions
# fastlane reports which actions are used. No personal data is recorded.
# Learn more at https://docs.fastlane.tools/#metrics
在 fastlane 這個(gè)大家庭中,主要但包括不盡于下列工具:
- scan 自動(dòng)化測(cè)試工具扇单,很好的封裝了 Unit Test
- sigh: 創(chuàng)建商模、更新、下載和修復(fù) provisioning profiles蜘澜。
- match 同步團(tuán)隊(duì)每個(gè)人的證書和 Provision file 的超贊工具
- cert: 自動(dòng)創(chuàng)建和維護(hù) iOS 代碼簽名證書施流。
- gym: 創(chuàng)建和打包 iOS app。
- deliver: 上傳屏幕截圖鄙信、元數(shù)據(jù)和 App 到 App 商店瞪醋。
- produce: 創(chuàng)建可用于 iTunes Connect 和 Apple Developer Portal 的 iOS app。
- snapshot: 自動(dòng)將 App屏幕截圖本地化到每種設(shè)備上装诡。
- frameit: 將屏幕截圖適配到適當(dāng)?shù)脑O(shè)備屏幕大小银受。
- PEM: 自動(dòng)創(chuàng)建和更新 Push 通知的 profile践盼。
fastlane 實(shí)戰(zhàn)
一、打一個(gè)測(cè)試包宾巍,并上傳到蒲公英交付測(cè)試.
1咕幻、創(chuàng)建一個(gè)匹配開發(fā)證書的lane
說(shuō)明:其中一個(gè)lane就是一個(gè)任務(wù),里面是一個(gè)個(gè)的action組成的工作流
打開fastlane文件夾下的Fastfile文件(最好用xcode打開)顶霞。
創(chuàng)建一個(gè)lane:格式如下
desc "匹配開發(fā)證書"
lane :matchDev do
match(type: "development", keychain_password: "git")
end
說(shuō)明:主要用到了match工具肄程,其中type
是指定環(huán)境,keychain_password
选浑,服務(wù)器鑰匙串密碼蓝厌,match工具當(dāng)然不止這些參數(shù),想了解更多參數(shù)可以在終端執(zhí)行fastlane action match
,或者fastlane match --help
來(lái)查看文檔古徒。
創(chuàng)建好了拓提,在終端執(zhí)行如下:
fastlane matchDev
[17:55:34]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[17:55:38]: -------------------------------------------------
[17:55:38]: --- Step: Verifying required fastlane version ---
[17:55:38]: -------------------------------------------------
[17:55:38]: Your fastlane version 2.68.2 matches the minimum requirement of 2.68.2 ?
[17:55:38]: ------------------------------
[17:55:38]: --- Step: default_platform ---
[17:55:38]: ------------------------------
[17:55:38]: Driving the lane 'ios matchDev' ??
[17:55:38]: -------------------
[17:55:38]: --- Step: match ---
[17:55:38]: -------------------
+-----------------------+------------------------+
| Summary for match 2.68.2 |
+-----------------------+------------------------+
| type | development |
| keychain_password | ******** |
| git_branch | master |
| app_identifier | com.jenkin.Debug |
| username | 這里顯示的是開發(fā)者賬號(hào) |
| keychain_name | login.keychain |
| readonly | false |
| team_id | 99WG99HF75 |
| verbose | false |
| force | false |
| skip_confirmation | false |
| shallow_clone | false |
| clone_branch_directly | false |
| force_for_new_devices | false |
| skip_docs | false |
| platform | ios |
+-----------------------+------------------------+
[17:55:38]: To not be asked about this value, you can specify it using 'git_url'
[17:55:38]: URL to the git repo containing all the certificates: git@172.16.11.154:repositories/test.git
[17:57:00]: Cloning remote git repo...
[17:57:00]: If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.
[17:57:00]: ?? Successfully decrypted certificates repo
[17:57:00]: Verifying that the certificate and profile are still valid on the Dev Portal...
[17:57:05]: Couldn't find a valid code signing identity in the git repo for development... creating one for you now
+-------------------+------------------------------------------------+
| Summary for cert 2.68.2 |
+-------------------+------------------------------------------------+
| development | true |
| force | true |
| username | 這里顯示的是開發(fā)者賬號(hào) |
| team_id | 99WG99HF75 |
| keychain_path | /Users/xyj/Library/Keychains/login.keychain-db |
| keychain_password | ******** |
| platform | ios |
+-------------------+------------------------------------------------+
[17:57:05]: Starting login with user '這里顯示的是開發(fā)者賬號(hào)'
[17:57:08]: Successfully logged in
[17:57:15]: Successfully generated FQV3SGXTZ9 which was imported to the local machine.
[17:57:17]: Verifying the certificate is properly installed locally...
[17:57:17]: Successfully installed certificate FQV3SGXTZ9
+-------------------------------------+------------------------------------+
| Summary for sigh 2.68.2 |
+-------------------------------------+------------------------------------+
| app_identifier | com.jenkin.Debug |
| username | 這里顯示的是開發(fā)者賬號(hào) |
| force | true |
| cert_id | FQV3SGXTZ9 |
| provisioning_name | match Development com.jenkin.Debug |
| ignore_profiles_with_different_name | true |
| team_id | 99WG99HF75 |
| platform | ios |
| development | true |
| adhoc | false |
| skip_install | false |
| skip_fetch_profiles | false |
| skip_certificate_verification | false |
| readonly | false |
+-------------------------------------+------------------------------------+
[17:57:19]: Starting login with user '這里顯示的是開發(fā)者賬號(hào)'
[17:57:21]: Successfully logged in
[17:57:21]: Fetching profiles...
[17:57:22]: Verifying certificates...
[17:57:25]: No existing profiles found, that match the certificates you have installed locally! Creating a new provisioning profile for you
[17:57:32]: The name 'match Development com.jenkin.Debug' is already taken, using another one.
[17:57:32]: Creating new provisioning profile for 'com.jenkin.Debug' with name 'match Development com.jenkin.Debug 1512640652' for 'ios' platform
[17:57:37]: Downloading provisioning profile...
[17:57:38]: Successfully downloaded provisioning profile...
[17:57:38]: Installing provisioning profile...
/var/folders/w9/q16q5ckx2k3b3vmskgh3ksx00000gn/T/d20171207-41012-161tif9/profiles/development/Development_com.jenkin.Debug.mobileprovision
[17:57:38]: Installing provisioning profile...
[17:57:40]: ?? Successfully encrypted certificates repo
[17:57:40]: Pushing changes to remote git repo...
+---------------------+------------------------------------------------+---------------------------------------------------------+
| Installed Provisioning Profile |
+---------------------+------------------------------------------------+---------------------------------------------------------+
| Parameter | Environment Variable | Value |
+---------------------+------------------------------------------------+---------------------------------------------------------+
| App Identifier | | com.jenkin.Debug |
| Type | | development |
| Platform | | ios |
| Profile UUID | sigh_com.jenkin.Debug_development | 8d811267-9a90-4186-84ff-849270910564 |
| Profile Name | sigh_com.jenkin.Debug_development_profile-name | match Development com.jenkin.Debug 1512640652 |
| Profile Path | sigh_com.jenkin.Debug_development_profile-path | /Users/xyj/Library/MobileDevice/Provisioning |
| | | Profiles/8d811267-9a90-4186-84ff-849270910564.mobilepr |
| | | ovision |
| Development Team ID | sigh_com.jenkin.Debug_development_team-id | 99WG99HF75 |
+---------------------+------------------------------------------------+---------------------------------------------------------+
[17:57:40]: All required keys, certificates and provisioning profiles are installed ??
[17:57:40]: Setting Provisioning Profile type to 'development'
+------+-------------------------------------+-------------+
| fastlane summary |
+------+-------------------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------------------+-------------+
| 1 | Verifying required fastlane version | 0 |
| 2 | default_platform | 0 |
| 3 | match | 122 |
+------+-------------------------------------+-------------+
[17:57:40]: fastlane.tools finished successfully ??
這里主要說(shuō)一下幾點(diǎn):
1、git_url
:git_url
是git服務(wù)器地址,我沒指定git_url
, 描函,匹配證書的時(shí)候崎苗,要求我輸入服務(wù)器地址。輸入完成后就會(huì)clone git服務(wù)器的代碼舀寓,
2胆数、驗(yàn)證證書:keychain_password就是為這步而存在的,這里由于我沒在git服務(wù)器下載證書互墓,所以沒找到必尼,但是fastlane為我重新創(chuàng)建了一個(gè)
3、描述文件:其實(shí)我已經(jīng)在證書(之前就創(chuàng)建的證書)上生成了描述文件篡撵,但是fastlane重新生成了證書判莉,所以他沒找到描述文件,又自動(dòng)給我重新生成了一個(gè)育谬。
上面三種情況是fastlane的正常流程券盅,但是我之前都創(chuàng)建好了,也就是說(shuō)他現(xiàn)在的操作不是我想看到的膛檀。接下來(lái)我們將匹配開發(fā)證書的lane改成下面這樣
desc "匹配開發(fā)證書"
lane :matchDev do
match(type: "development", keychain_password: "git", git_url: "git@172.16.11.154:repositories/test.git")
end
并且登錄開發(fā)者賬號(hào)將新生成的證書和描述文件都刪掉锰镀,登錄git服務(wù)器,將證書下載并安裝好
再次在終端運(yùn)行,結(jié)果如下:
fastlane matchDev
[11:12:18]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[11:12:21]: -------------------------------------------------
[11:12:21]: --- Step: Verifying required fastlane version ---
[11:12:21]: -------------------------------------------------
[11:12:21]: Your fastlane version 2.68.2 matches the minimum requirement of 2.68.2 ?
[11:12:21]: ------------------------------
[11:12:21]: --- Step: default_platform ---
[11:12:21]: ------------------------------
[11:12:21]: Driving the lane 'ios matchDev' ??
[11:12:21]: -------------------
[11:12:21]: --- Step: match ---
[11:12:21]: -------------------
+-----------------------+-----------------------------------------+
| Summary for match 2.68.2 |
+-----------------------+-----------------------------------------+
| type | development |
| git_url | git@172.16.11.154:repositories/test.git |
| force | true |
| git_branch | master |
| app_identifier | com.jenkin.Debug |
| username | 這里顯示的是開發(fā)者賬號(hào) |
| keychain_name | login.keychain |
| readonly | false |
| team_id | 99WG99HF75 |
| verbose | false |
| skip_confirmation | false |
| shallow_clone | false |
| clone_branch_directly | false |
| force_for_new_devices | false |
| skip_docs | false |
| platform | ios |
+-----------------------+-----------------------------------------+
[11:12:21]: Cloning remote git repo...
[11:12:21]: If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.
[11:12:22]: ?? Successfully decrypted certificates repo
[11:12:22]: Verifying that the certificate and profile are still valid on the Dev Portal...
[11:12:26]: Installing certificate...
+-------------------+----------------------------------------------------------+
| Installed Certificate |
+-------------------+----------------------------------------------------------+
| User ID | BED2DYAVHS |
| Common Name | 這里顯示證書名字
|
| Organisation Unit | 99WG99HF75 |
| Organisation | ******** |
| Country | US |
| Start Datetime | Dec 8 02:58:55 2017 GMT |
| End Datetime | Dec 8 02:58:55 2018 GMT |
+-------------------+----------------------------------------------------------+
+-------------------------------------+------------------------------------+
| Summary for sigh 2.68.2 |
+-------------------------------------+------------------------------------+
| app_identifier | com.jenkin.Debug |
| username | 這里顯示的是開發(fā)者賬號(hào) |
| force | true |
| cert_id | SP54MR68FC |
| provisioning_name | match Development com.jenkin.Debug |
| ignore_profiles_with_different_name | true |
| team_id | 99WG99HF75 |
| platform | ios |
| development | true |
| adhoc | false |
| skip_install | false |
| skip_fetch_profiles | false |
| skip_certificate_verification | false |
| readonly | false |
+-------------------------------------+------------------------------------+
[11:12:27]: Starting login with user '這里顯示的是開發(fā)者賬號(hào)'
[11:12:30]: Successfully logged in
[11:12:30]: Fetching profiles...
[11:12:31]: Verifying certificates...
[11:12:32]: Found 1 matching profile(s)
[11:12:32]: Recreating the profile
[11:12:34]: Creating new provisioning profile for 'com.jenkin.Debug' with name 'match Development com.jenkin.Debug' for 'ios' platform
[11:12:35]: Downloading provisioning profile...
[11:12:35]: Successfully downloaded provisioning profile...
[11:12:36]: Installing provisioning profile...
/var/folders/w9/q16q5ckx2k3b3vmskgh3ksx00000gn/T/d20171208-50529-1yh4aue/profiles/development/Development_com.jenkin.Debug.mobileprovision
[11:12:36]: Installing provisioning profile...
[11:12:37]: ?? Successfully encrypted certificates repo
[11:12:37]: Pushing changes to remote git repo...
+---------------------+------------------------------------+------------------------------------+
| Installed Provisioning Profile |
+---------------------+------------------------------------+------------------------------------+
| Parameter | Environment Variable | Value |
+---------------------+------------------------------------+------------------------------------+
| App Identifier | | com.jenkin.Debug |
| Type | | development |
| Platform | | ios |
| Profile UUID | sigh_com.jenkin.Debug_development | 63075bad-3ee8-449e-9ebb-251c50ea7 |
| | | f0c |
| Profile Name | sigh_com.jenkin.Debug_development | match Development |
| | _profile-name | com.jenkin.Debug |
| Profile Path | sigh_com.jenkin.Debug_development | /Users/xyj/Library/MobileDevice/P |
| | _profile-path | rovisioning |
| | | Profiles/63075bad-3ee8-449e-9ebb- |
| | | 251c50ea7f0c.mobileprovision |
| Development Team ID | sigh_com.jenkin.Debug_development | 99WG99HF75 |
| | _team-id | |
+---------------------+------------------------------------+------------------------------------+
[11:12:37]: All required keys, certificates and provisioning profiles are installed ??
[11:12:37]: Setting Provisioning Profile type to 'development'
+------+------------------------------+-------------+
| fastlane summary |
+------+------------------------------+-------------+
| Step | Action | Time (in s) |
+------+------------------------------+-------------+
| 1 | Verifying required fastlane | 0 |
| | version | |
| 2 | default_platform | 0 |
| 3 | match | 16 |
+------+------------------------------+-------------+
[11:12:37]: fastlane.tools finished successfully ??
完成上面的步驟后咖刃,clone下你的代碼泳炉。工程下面多了兩個(gè)文件夾certs
、profiles
- certs文件夾下面包含一個(gè).cer文件和一個(gè).p12文件嚎杨。命名都是以證書id,這兩個(gè)文件分別用于自己開發(fā)和授權(quán)團(tuán)隊(duì)的小伙伴開發(fā)的花鹅。
- profiles文件夾下面存放的是描述文件
當(dāng)你的倉(cāng)庫(kù)里面沒這兩個(gè),fastlane會(huì)為你重新創(chuàng)建證書和描述文件枫浙。如果有了刨肃。那就是上面這種情況古拴,fastlane會(huì)直接幫你匹配好證書和描述文件。
至此之景,創(chuàng)建一個(gè)匹配開發(fā)證書的lane就算完成了斤富。
2.創(chuàng)建一個(gè)打測(cè)試包的lane
創(chuàng)建一個(gè)lane,格式如下:
desc "打測(cè)試包"
desc "This will also make sure the profile is up to date"
lane :expIpa do
gym(clean: true, export_method: "development", configuration: "Debug")
end
這里主要涉及的工具為gym
,命令包含clean
,export_method
,configuration
三個(gè)參數(shù)锻狗,分別的含義為編譯之前是否clean满力、導(dǎo)出archive包的方式、編譯哪個(gè)configuration轻纪。
想了解更多參數(shù)油额,可在終端輸入fastlane action gym
或fastlane gym --help
查看文檔。
執(zhí)行上面的命令后刻帚,在工程目錄下可以看到導(dǎo)出的ipa包潦嘶。沒指定名字的話,ipa包的名字就是你的工程名崇众。
3.創(chuàng)建一個(gè)上傳到測(cè)試包到第三方分發(fā)平臺(tái)的lane掂僵,這里以蒲公英為例
上傳測(cè)試包到蒲公英、firim等第三方平臺(tái)顷歌,都要到相應(yīng)的第三方平臺(tái)注冊(cè)賬號(hào)锰蓬,這些平臺(tái)一般都會(huì)制作fastlane的插件來(lái)支持fastlane上傳測(cè)試包,這里做簡(jiǎn)單的介紹,查看詳細(xì)文檔請(qǐng)查看蒲公英官方文檔眯漩。
1芹扭、查看、安裝fastlane插件
在終端輸入 fastlane search_plugins
可以查看當(dāng)前版本所有可用的插件赦抖,可以在里面看到pgyer
插件,想知道如何使用請(qǐng)異步蒲公英官網(wǎng)查看舱卡。
安裝pgyer插件:
fastlane add_plugin pgyer
安裝完成后你就可以使用fastlane action pgyer
來(lái)查看相關(guān)的參數(shù)以及使用了。
官網(wǎng)給出的例子是:
lane :beta do
gym(export_method: "ad-hoc")
pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e")
end
以上的 api_key 和 user_key队萤,請(qǐng)開發(fā)者在自己賬號(hào)(蒲公英)下的 應(yīng)用管理 - App概述 - API 中可以找到轮锥,并替換到以上相應(yīng)的位置。
上面要尔,我們已經(jīng)打好測(cè)試包了交胚,下面我們就上傳測(cè)試到蒲公英。
lane如下:
desc "上傳到蒲公英"
lane :uploadPGY do
pgyer(api_key: "75284caf4b30813b45b557ca7d121b2d", user_key: "fa8d179bb6b6cf382931ee2e487e2321",ipa: "JenkinsDemo.ipa")
end
執(zhí)行結(jié)果如下:
? test git:(master) ? fastlane uploadPGY
+-----------------------+---------+--------+
| Used plugins |
+-----------------------+---------+--------+
| Plugin | Version | Action |
+-----------------------+---------+--------+
| fastlane-plugin-pgyer | 0.2.1 | pgyer |
+-----------------------+---------+--------+
[10:48:01]: -------------------------------------------------
[10:48:01]: --- Step: Verifying required fastlane version ---
[10:48:01]: -------------------------------------------------
[10:48:01]: Your fastlane version 2.68.2 matches the minimum requirement of 2.68.2 ?
[10:48:01]: ------------------------------
[10:48:01]: --- Step: default_platform ---
[10:48:01]: ------------------------------
[10:48:01]: Driving the lane 'ios uploadPGY' ??
[10:48:01]: -------------------
[10:48:01]: --- Step: pgyer ---
[10:48:01]: -------------------
[10:48:01]: The pgyer plugin is working.
[10:48:01]: build_file: JenkinsDemo.ipa
[10:48:01]: Start upload JenkinsDemo.ipa to pgyer...
[10:48:45]: Upload success. Visit this URL to see: https://www.pgyer.com/LnYN
+------+-------------------------------------+-------------+
| fastlane summary |
+------+-------------------------------------+-------------+
| Step | Action | Time (in s) |
+------+-------------------------------------+-------------+
| 1 | Verifying required fastlane version | 0 |
| 2 | default_platform | 0 |
| 3 | pgyer | 43 |
+------+-------------------------------------+-------------+
[10:48:45]: fastlane.tools finished successfully ??
可以看到盈电,上傳成功后會(huì)給出一個(gè)鏈接,測(cè)試只需要打開這個(gè)鏈接就能掃碼安裝測(cè)試包了
小結(jié):
上面幾個(gè)步驟杯活,其實(shí)是可以在一個(gè)lane里面完成的匆帚。我改進(jìn)后的lane如下
desc "打測(cè)試包并上傳蒲公英"
lane :dev do
# 調(diào)用匹配開發(fā)證書的lane
matchDev
expIpa
uploadPGY
end
當(dāng)然,你可以這樣:
desc "打測(cè)試包并上傳蒲公英"
lane :dev do
match(type: "development", git_url: "git@172.16.11.154:repositories/test.git")
gym(clean: true, export_method: "development", configuration: "Debug")
pgyer(api_key: "75284caf4b30813b45b557ca7d121b2d", user_key: "fa8d179bb6b6cf382931ee2e487e2321",ipa: "JenkinsDemo.ipa")
end
這兩種方法旁钧,本質(zhì)上是一樣的吸重。上面只不過(guò)是lane之間的相互調(diào)用互拾。
二、上傳一個(gè)TestFlight的測(cè)試包嚎幸,
命令如下
desc "打beta包上傳TestFlight"
lane :beta do
match(type: "appstore", git_url: "git@172.16.11.154:repositories/test.git")
build_app(clean: true, output_name: "appstore", configuration: "Release", include_bitcode: true)
testflight(skip_submission: true)# 上傳testflight
end
上傳之前請(qǐng)做好前期的準(zhǔn)備工作颜矿,在開發(fā)者賬號(hào)上創(chuàng)建APP,xcode上添加好appicon等嫉晶。
首先:前期的匹配證書骑疆、導(dǎo)出ipa文件和打測(cè)試包差不多,改一下相應(yīng)的參數(shù)就行了替废。只是增加了上傳到TestFlight箍铭,并且只是上傳一個(gè)ipa包并沒有將app相關(guān)的信息也上傳到TestFlight。
我在測(cè)試過(guò)程中遇到的問(wèn)題:
1椎镣、因?yàn)槭菧y(cè)試诈火,所以一開始沒有添加相應(yīng)尺寸的appicon,導(dǎo)致失敗状答。
2冷守、在成功導(dǎo)出ipa包,準(zhǔn)備上傳的時(shí)候報(bào)錯(cuò)惊科,如下圖 :
原因:上次上傳的動(dòng)作被被記錄在UploadToken
文件夾下面了拍摇,我們要進(jìn)入user/.itmstransporter/UploadTokens
該目錄下將里面的文件刪除,再次運(yùn)行fastlane beta
命令译断,就能上傳成功了授翻,上傳過(guò)程會(huì)比較久,但終端會(huì)顯示上傳的進(jìn)度,大概如下
DEBUG [2017-12-09 17:39:46.83]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 1880200/93265945, 2% completed
DEBUG [2017-12-09 17:40:07.92]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 3744600/93265945, 4% completed
DEBUG [2017-12-09 17:40:16.55]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 4676800/93265945, 5% completed
DEBUG [2017-12-09 17:40:24.74]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 5609000/93265945, 6% completed
DEBUG [2017-12-09 17:40:36.80]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 6541200/93265945, 7% completed
DEBUG [2017-12-09 17:40:55.42]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 8405600/93265945, 9% completed
DEBUG [2017-12-09 17:41:09.38]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 9337800/93265945, 10% completed
DEBUG [2017-12-09 17:41:20.30]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 10270000/93265945, 11% completed
DEBUG [2017-12-09 17:41:39.45]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 12134400/93265945, 13% completed
DEBUG [2017-12-09 17:41:49.63]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 13066600/93265945, 14% completed
DEBUG [2017-12-09 17:41:58.10]: [Transporter]: INFO: File: 9a0450527b7b0dd213f32d8ad7a043d2.ipa 13998800/93265945, 15% completed
如果要直接上傳appstore孙咪,將上面的testfligh
t命令換成pload_to_app_store
命令就可以了堪唐。(因?yàn)檫@是制作demo,所以沒具體操作)翎蹈。請(qǐng)自行嘗試淮菠!
結(jié)語(yǔ)
這篇博客只是提及了比較常用,也是比較實(shí)用的功能荤堪。起到拋磚引玉的作用fastlane
還有很多強(qiáng)大的功能合陵,這里沒有一一提及,有興趣的小伙伴可以多多研究
相關(guān)的知識(shí):
atool
xcodebuild 自動(dòng)化構(gòu)建
蘋果下使用Gitosis的搭建git的服務(wù)器
fastlane文檔