iOS Fastlane 使用文檔


更新時間:2019-4-8

一莺掠、開始使用前的準(zhǔn)備工作檢查環(huán)境配置:

1筛欢、檢查ruby

命令:ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

如果沒有安裝請晃听,移步這里

2、Xcode命令工具

命令:xcode-select -v
xcode-select version 2354.
如果沒有安裝介却,就安裝命令:xcode-select --install

3谴供、安裝fastlane

sudo gem install fastlane --verbose

如果安裝失敗:

ERROR:  While executing gem ... (TypeError)
    no implicit conversion of nil into String

進行更新gem:

sudo gem update --system

安裝成功:

?  1.0 fastlane -v
Ignoring bigdecimal-1.3.5 because its extensions are not built.  Try: gem pristine bigdecimal --version 1.3.5
fastlane installation at path:
/Library/Ruby/Gems/2.3.0/gems/fastlane-2.112.0/bin/fastlane
-----------------------------
[?] ?? Ignoring io-console-0.4.6 because its extensions are not built.  Try: gem pristine io-console --version 0.4.6
Ignoring nokogiri-1.8.4 because its extensions are not built.  Try: gem pristine nokogiri --version 1.8.4
Ignoring psych-3.0.2 because its extensions are not built.  Try: gem pristine psych --version 3.0.2
Ignoring sqlite3-1.3.13 because its extensions are not built.  Try: gem pristine sqlite3 --version 1.3.13
[?] ?? 
fastlane 2.112.0

二齿坷、項目初始化

fastlane init

出現(xiàn)如下信息:

[15:08:29]: What would you like to use fastlane for?
1. ??  Automate screenshots
2. ?????  Automate beta distribution to TestFlight
3. ??  Automate App Store distribution
4. ??  Manual setup - manually setup your project to automate your tasks
?  

翻譯:
1. 自動截屏桂肌。這個功能能幫我們自動截取APP中的截圖数焊,并添加手機邊框(如果需要的話),我們這里不選擇這個選項崎场,因為我們的項目已經(jīng)有圖片了佩耳,不需要這里截屏。
2. 自動發(fā)布beta版本用于TestFlight谭跨,如果大家有對TestFlight不了解的干厚,可以參考王巍寫的這篇文章
3. 自動的App Store發(fā)布包。我們的目標(biāo)是要提交審核到APP Store螃宙,按道理應(yīng)該選這個蛮瞄,但這里我們先不選,因為選擇了以后會需要輸入用戶名密碼谆扎,以及下載meta信息挂捅,需要花費一定時間,這些數(shù)據(jù)我們可以后期進行配置燕酷。
4. 手動設(shè)置籍凝。

直接選擇第4個對其進行手動配置后進入:

[15:17:15]: ------------------------------------------------------------
[15:17:15]: --- Setting up fastlane so you can manually configure it ---
[15:17:15]: ------------------------------------------------------------
[15:17:15]: Installing dependencies for you...
[15:17:15]: $ bundle update

等待時間較長.....
安裝成功如下:

?  1.0 fastlane init
Ignoring bigdecimal-1.3.5 because its extensions are not built.  Try: gem pristine bigdecimal --version 1.3.5
[?] ?? Ignoring io-console-0.4.6 because its extensions are not built.  Try: gem pristine io-console --version 0.4.6
Ignoring nokogiri-1.8.4 because its extensions are not built.  Try: gem pristine nokogiri --version 1.8.4
Ignoring psych-3.0.2 because its extensions are not built.  Try: gem pristine psych --version 3.0.2
Ignoring sqlite3-1.3.13 because its extensions are not built.  Try: gem pristine sqlite3 --version 1.3.13
[?] ?? 
[15:37:31]: ------------------------------
[15:37:31]: --- Step: default_platform ---
[15:37:31]: ------------------------------

--------- ios---------
----- fastlane ios custom_lane
Description of what the lane does

Execute using `fastlane [lane_name]`
[15:37:31]: ------------------
[15:37:31]: fastlane is already set up at path `./fastlane/`, see the available lanes above
[15:37:31]: 
[15:37:31]: ------------------------------
[15:37:31]: --- Where to go from here? ---
[15:37:31]: ------------------------------
[15:37:31]: ??  Learn more about how to automatically generate localized App Store screenshots:
[15:37:31]:         https://docs.fastlane.tools/getting-started/ios/screenshots/
[15:37:31]: ?????  Learn more about distribution to beta testing services:
[15:37:31]:         https://docs.fastlane.tools/getting-started/ios/beta-deployment/
[15:37:31]: ??  Learn more about how to automate the App Store release process:
[15:37:31]:         https://docs.fastlane.tools/getting-started/ios/appstore-deployment/
[15:37:31]: ?????  Learn more about how to setup code signing with fastlane
[15:37:31]:         https://docs.fastlane.tools/codesigning/getting-started/
?  1.0 

其他命令:

fastlane actions:      列出所有可用fastlane活動
fastlane action [action_name]:   顯示一個更詳細的活動描述
fastlane lanes:      列出所有可用lanes (有描述)
fastlane list:       列出所有可用lanes (沒有描述)
fastlane new_action:     在fastlane創(chuàng)建一個活動(集成)

三献起、對fastlane 文件的認(rèn)識:

現(xiàn)在對Appfile刊驴,F(xiàn)astfile承二,Gemfile十气,Deliverfile文件說明如下:

Appfile: 存儲有關(guān)開發(fā)者賬號相關(guān)信息
Fastfile: 核心文件发侵,用于命令行調(diào)用和處理具體的流程辐宾,lane相對于一個action方法或函數(shù) 
Gemfile 類似于cocopods 的Podfile文件
.env 配置環(huán)境變量(在fastlane init進行初始化后并不會自動生成奄喂,如果需要可以自己創(chuàng)建
Deliverfile: deliver工具的配置文件撤师,上傳截圖蘋果和后臺一些app信息  (默認(rèn)不生成泻肯,需要sudo gem install deliver安裝)然后在fastlane 目錄下執(zhí)行deliver init 即可)
要注意的點:
build_app命令等同于gym(別名)
deliver 命令相當(dāng)于upload_to_app_store(別名)

四渊迁、添加插件

列出所有的插件

fastlane search_plugins

搜索指定名稱的插件

fastlane search_plugins [query]

添加插件

fastlane add_plugin [name]

安裝插件

fastlane install_plugins

添加蒲公英插件
fastlane add_plugin pgyer
fastlane add_plugin versioning

添加match全家桶

fastlane match init

五、配置相關(guān)文件信息

配置主文件:Fastfile
配置證書的存放路徑

fastlane ios
[16:42:53]: $ bundle exec fastlane ios
[16:42:53]: 
[16:42:53]: 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.2   | pgyer                  |
| fastlane-plugin-versi  | 0.3.4   | get_version_number_fr  |
| oning                  |         | om_git_branch          |
|                        |         | get_version_number_fr  |
|                        |         | om_plist               |
|                        |         | get_build_number_from  |
|                        |         | _plist                 |
|                        |         | ci_build_number        |
|                        |         | increment_version_num  |
|                        |         | ber_in_plist           |
|                        |         | get_app_store_version  |
|                        |         | _number                |
|                        |         | get_info_plist_path    |
|                        |         | increment_build_numbe  |
|                        |         | r_in_plist             |
+------------------------+---------+------------------------+

[16:42:55]: ------------------------------
[16:42:55]: --- Step: default_platform ---
[16:42:55]: ------------------------------
[16:42:55]: Welcome to fastlane! Here's what your app is setup to do:
+--------+-----------------+----------------------+
|             Available lanes to run              |
+--------+-----------------+----------------------+
| Number | Lane Name       | Description          |
+--------+-----------------+----------------------+
| 1      | ios custom_lane | Description of what  |
|        |                 | the lane does        |
| 0      | cancel          | No selection, exit   |
|        |                 | fastlane!            |
+--------+-----------------+----------------------+
[16:42:55]: Which number would you like run?

六灶挟、遇到問題

出現(xiàn)錯誤:

[17:13:49]: ? ** ARCHIVE SUCCEEDED **
[17:13:49]: 
[17:13:49]: ??  Check out the few lines of raw `xcodebuild` output above for potential hints on how to solve this error
[17:13:49]: ??  For the complete and more detailed error log, check the full log at:
[17:13:49]: ??  /Users/liujingxu/Library/Logs/gym/M-Pay-M-Pay.log
[17:13:49]: 
[17:13:49]: Looks like fastlane ran into a build/archive error with your project
[17:13:49]: It's hard to tell what's causing the error, so we wrote some guides on how
[17:13:49]: to troubleshoot build and signing issues: https://docs.fastlane.tools/codesigning/getting-started/
[17:13:49]: Before submitting an issue on GitHub, please follow the guide above and make
[17:13:49]: sure your project is set up correctly.
[17:13:49]: fastlane uses `xcodebuild` commands to generate your binary, you can see the
[17:13:49]: the full commands printed out in yellow in the above log.
[17:13:49]: Make sure to inspect the output above, as usually you'll find more error information there
[17:13:49]: 
[17:13:49]: Looks like no provisioning profile mapping was provided
[17:13:49]: Please check the complete output, in particular the very top
[17:13:49]: and see if you can find more information. You can also run fastlane
[17:13:49]: with the `--verbose` flag.
[17:13:49]: Alternatively you can provide the provisioning profile mapping manually
[17:13:49]: https://docs.fastlane.tools/codesigning/xcode-project/#xcode-9-and-up
+------------------+---------------+
|           Lane Context           |
+------------------+---------------+
| DEFAULT_PLATFORM | ios           |
| PLATFORM_NAME    | ios           |
| LANE_NAME        | ios adhoc_pgy |
| BUILD_NUMBER     | 2             |
+------------------+---------------+
[17:13:49]: Error packaging up the application

+------+------------------------+-------------+
|              fastlane summary               |
+------+------------------------+-------------+
| Step | Action                 | Time (in s) |
+------+------------------------+-------------+
| 1    | default_platform       | 0           |
| 2    | cocoapods              | 3           |
| 3    | increment_build_numbe  | 1           |
|      | r                      |             |
| ??   | build_app              | 84          |
+------+------------------------+-------------+

[17:13:49]: fastlane finished with errors

[!] Error packaging up the application

match文件配置

  1. 首頁需要一個git倉庫用來存放Cer證書
  2. git 倉庫需要添加ssh公鑰
生產(chǎn)密鑰:ssh-keygen 
查看密鑰:cat ~/.ssh/id_rsa.pub

2琉朽、錯誤信息

[16:19:23]: URL to the git repo containing all the certificates: https://gitee.com/mxlj/M-Pay-Cer.git
[16:19:33]: Cloning remote git repo...
[16:19:33]: If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.
Cloning into '/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/d20190409-13299-1p3m5n2'...
fatal: could not read Username for 'https://gitee.com': terminal prompts disabled
[16:19:34]: Exit status: 128
[16:19:34]: Error cloning certificates repo, please make sure you have read access to the repository you want to use
[16:19:34]: Run the following command manually to make sure you're properly authenticated:
[16:19:34]: $ git clone https://gitee.com/mxlj/M-Pay-Cer.git /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/d20190409-13299-1p3m5n2

[!] Error cloning certificates git repo, please make sure you have access to the repository - see instructions above

解決方法:

注:出現(xiàn)這個問題是因為mac git終端沒有讀寫的權(quán)限,問題稚铣。
未找到修改權(quán)限的方法來解決此問題箱叁,所有使用下面的方面來解決。

運行:

git clone https://gitee.com/mxlj/M-Pay-Cer.git /var/folders/xc/bzrxbntn1fq_fw53ks0_jbzc0000gn/T/d20190409-13848-156jw68

提示輸入git的賬號:xxx@.com
提示輸入git的密碼:xxxx

這樣就進行了git倉庫的關(guān)聯(lián)惕医。

運行:fastlane match adhoc,需要輸入app賬號的密碼

然后需要確認(rèn)使用哪個組織來進行證書下載耕漱,在打包的時候也是。

還有一個git倉庫的密碼:123456抬伺,這個密碼在其他的電腦上會使用到螟够,會去倉庫里下載證書.

問題:

Couldn't find specified scheme 'scheme'. Please make sure that the scheme is shared, see https://developer.apple.com/library/content/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/ConfigureBots.html#//apple_ref/doc/uid/TP40013292-CH9-SW3

修改Fastlane文件的scheme:為項目名稱

報satus 70錯誤

** EXPORT FAILED **
[17:28:29]: Exit status: 70

解決辦法:
把xcode證書自動管理修改為手段管理,就可以解決此問題。
至于具體原因未找到妓笙。

問題

[09:50:03]: Could not find action, lane or variable 'pgyer'. Check out the documentation for more details: https://docs.fastlane.tools/actions

+------+------------------+-------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
| 2    | sigh             | 17          |
| 3    | gym              | 67          |
+------+------------------+-------------+

[09:50:03]: fastlane finished with errors

[!] Could not find action, lane or variable 'pgyer'. Check out the documentation for more details: https://docs.fastlane.tools/actions

解決:

是因為無法找到蒲公英的插件若河,腳本里加了,但是命令沒有加给郊。

fastlane add_plugin pgyer
//版本管理
fastlane add_plugin versioning


完成上傳成功

iOS打包命令

ios test

fastlane ios test

ios release

fastlane ios release

ios appstore

fastlane ios appstore

其他注意事項

當(dāng)已經(jīng)創(chuàng)建好了主的fastlane的證書牡肉,其他電腦上只獲取就可以了:

fastlane match development readonly

fastlane match adhoc readonly

添加新設(shè)備后更新證書
fastlane match development --force_for_new_devices

fastlane match adhoc --force_for_new_devices


rom the Apple Dev Portal
    nuke development    Delete all certificates and provisioning profiles
from the Apple Dev Portal of the type development
    nuke distribution   Delete all certificates and provisioning profiles
from the Apple Dev Portal of the type distribution
    nuke enterprise     Delete all certificates and provisioning profiles
from the Apple Dev Portal of the type enterprise
    run               * Easily sync your certificates and profiles across
your team

分割線


xcode 多config配置

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市淆九,隨后出現(xiàn)的幾起案子统锤,更是在濱河造成了極大的恐慌,老刑警劉巖炭庙,帶你破解...
    沈念sama閱讀 212,454評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件饲窿,死亡現(xiàn)場離奇詭異,居然都是意外死亡焕蹄,警方通過查閱死者的電腦和手機逾雄,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,553評論 3 385
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來腻脏,“玉大人鸦泳,你說我怎么就攤上這事∮榔罚” “怎么了做鹰?”我有些...
    開封第一講書人閱讀 157,921評論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長鼎姐。 經(jīng)常有香客問我钾麸,道長,這世上最難降的妖魔是什么炕桨? 我笑而不...
    開封第一講書人閱讀 56,648評論 1 284
  • 正文 為了忘掉前任饭尝,我火速辦了婚禮,結(jié)果婚禮上献宫,老公的妹妹穿的比我還像新娘钥平。我一直安慰自己,他們只是感情好姊途,可當(dāng)我...
    茶點故事閱讀 65,770評論 6 386
  • 文/花漫 我一把揭開白布帖池。 她就那樣靜靜地躺著,像睡著了一般吭净。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上肴甸,一...
    開封第一講書人閱讀 49,950評論 1 291
  • 那天寂殉,我揣著相機與錄音,去河邊找鬼原在。 笑死友扰,一個胖子當(dāng)著我的面吹牛彤叉,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播村怪,決...
    沈念sama閱讀 39,090評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼秽浇,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了甚负?” 一聲冷哼從身側(cè)響起柬焕,我...
    開封第一講書人閱讀 37,817評論 0 268
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎梭域,沒想到半個月后斑举,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,275評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡病涨,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,592評論 2 327
  • 正文 我和宋清朗相戀三年富玷,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片既穆。...
    茶點故事閱讀 38,724評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡赎懦,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出幻工,到底是詐尸還是另有隱情励两,我是刑警寧澤,帶...
    沈念sama閱讀 34,409評論 4 333
  • 正文 年R本政府宣布会钝,位于F島的核電站伐蒋,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏迁酸。R本人自食惡果不足惜先鱼,卻給世界環(huán)境...
    茶點故事閱讀 40,052評論 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望奸鬓。 院中可真熱鬧焙畔,春花似錦、人聲如沸串远。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,815評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽澡罚。三九已至伸但,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間留搔,已是汗流浹背更胖。 一陣腳步聲響...
    開封第一講書人閱讀 32,043評論 1 266
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人却妨。 一個月前我還...
    沈念sama閱讀 46,503評論 2 361
  • 正文 我出身青樓饵逐,卻偏偏與公主長得像,于是被迫代替她去往敵國和親彪标。 傳聞我的和親對象是個殘疾皇子倍权,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,627評論 2 350

推薦閱讀更多精彩內(nèi)容

  • fastlane運行所需要的環(huán)境: OS X 10.9以上 Ruby 2.0 以上 Xcode 擁有一個開發(fā)者賬號...
    阿姣_0405閱讀 2,947評論 0 4
  • 毋庸置疑,Jenkins對我們打包的幫助還是很大的——被測試的同學(xué)追著要IPA包的日子終于一去不復(fù)返了捞烟。但作為追求...
    iOS逆向開發(fā)閱讀 1,543評論 2 10
  • 毋庸置疑薄声,Jenkins對我們打包的幫助還是很大的——被測試的同學(xué)追著要IPA包的日子終于一去不復(fù)返了。但作為追求...
    _VisitorsZsl閱讀 1,152評論 0 4
  • 前言:一直有聽過腳本一鍵打包審核坷襟,但是自己一直沒在意奸柬。在微信公眾號看到ios一鍵打包的文章,突然想想自己每次從打包...
    光彩影閱讀 5,601評論 1 42
  • 親愛的寶貝桌粉,你好! 今天一大早起來你又哭了衙四,因為我沒有五點鐘叫你起床寫作業(yè)铃肯。可是寶貝传蹈,你除了日記外押逼,昨天其它作業(yè)不...
    91b6f8355762閱讀 197評論 0 0