初識(shí)fastlane

fastlane

fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. ?? It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application.

舉個(gè)例子跳芳,在項(xiàng)目根目錄創(chuàng)建包含以下內(nèi)容的Fastfile文件:

lane :beta do
  increment_build_number
  build_app
  upload_to_testflight
end

lane :release do
  capture_screenshots
  build_app
  upload_to_app_store       # Upload the screenshots     and the binary to iTunes
  slack                     # Let your team-mates know the     new version is live
end

這是兩段fastlane的命令集

然后嘶朱,需要執(zhí)行哪段命令只需要 操作命令 fastlane beta/release即可讓程序自動(dòng)有序地執(zhí)行所有操作材义。


Getting Started for iOS

Install the latest Xcode command line tools:

xcode-select --install

Install fastlane using

# Using RubyGems
sudo gem install fastlane -NV

# Alternatively using Homebrew
brew cask install fastlane

Navigate to your iOS app and run

fastlane init

fastlane will automatically detect your project, and ask for any missing information.

gz-tankmm:TestForImage tank$ fastlane init
[?] ?? 
[?] Looking for iOS and Android projects in     current directory...
[12:28:02]: Created new folder './fastlane'.
[12:28:02]: Detected an iOS/macOS project in the   current directory: 'TestForImage.xcworkspace'
[12:28:02]: -----------------------------
[12:28:02]: --- Welcome to fastlane ?? ---
[12:28:02]: -----------------------------
[12:28:02]: fastlane can help you with all kinds of automation for your mobile app
[12:28:02]: We recommend automating one task     first, and then gradually automating more over time
[12:28:02]: 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
?  

命令執(zhí)行會(huì)生成fastlane文件夾或南,并需要一步步跟著配置fastlane宜咒, 以及根據(jù)需求相應(yīng)地配置該項(xiàng)目設(shè)置。
根據(jù)用戶作出的不同需求選擇梦抢,會(huì)在該文件夾生成不同的配置文件官撼。其中最重要的是fastlane/Fastfile這個(gè)文件,里面包含了所有需要配置項(xiàng)目的信息劣挫。

比如以上選擇了 1. ?? Automate screenshots則會(huì)需求手動(dòng)配置項(xiàng)目:

[12:31:40]: Parsing your local Xcode project to find     the available schemes and the app identifier
[12:31:40]: $ xcodebuild -showBuildSettings -workspace TestForImage.xcworkspace -scheme   TestForImage
?  Successfully created SnapshotHelper.swift './fastlane/SnapshotHelper.swift'
?  Successfully created new Snapfile at './fastlane/Snapfile'
-------------------------------------------------------
Open your Xcode project and make sure to do the     following:
1) Add a new UI Test target to your project
2) Add the ./fastlane/SnapshotHelper.swift to your UI Test target
   You can move the file anywhere you want
3) Call `setupSnapshot(app)` when launching your app

    let app = XCUIApplication()
    setupSnapshot(app)
    app.launch()

4) Add `snapshot("0Launch")` to wherever you want to trigger screenshots
5) Add a new Xcode scheme for the newly created UITest target
6) Add a Check to enable the `Shared` box of the newly created scheme

這時(shí)候可以看到fastlane/Fastfile長(zhǎng)這樣的:

fastlane/Fastfile

里面包含了截圖并上傳到appstore的相關(guān)命令册养,隨后只需要在項(xiàng)目路徑下執(zhí)行fastlane screenshots就可以自動(dòng)執(zhí)行這些操作了。

在配置fastlane的過(guò)程中压固,也會(huì)自動(dòng)在項(xiàng)目根目錄下生成Gemfile以及Gemfile.lock文件球拦,里面定義了fastlane的版本和依賴,這會(huì)提高使用fastlane的速度帐我,這也是官方推薦的坎炼。

更多的自動(dòng)命令集參考 https://docs.fastlane.tools/actions/

自定義動(dòng)作

除了fastlane官方預(yù)置的動(dòng)作外,更多的是使用自定義的適合自己的動(dòng)作:


自定義fastlane命令集

這里創(chuàng)建了一個(gè)build_qa的腳本拦键,使用fastlane build_qa啟動(dòng)執(zhí)行谣光,進(jìn)行觸發(fā)bitrise build qa .ipa的一系列操作。

更多參考官方文檔

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末芬为,一起剝皮案震驚了整個(gè)濱河市抢肛,隨后出現(xiàn)的幾起案子狼钮,更是在濱河造成了極大的恐慌碳柱,老刑警劉巖捡絮,帶你破解...
    沈念sama閱讀 222,252評(píng)論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異莲镣,居然都是意外死亡福稳,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門瑞侮,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)的圆,“玉大人,你說(shuō)我怎么就攤上這事半火≡铰瑁” “怎么了?”我有些...
    開封第一講書人閱讀 168,814評(píng)論 0 361
  • 文/不壞的土叔 我叫張陵钮糖,是天一觀的道長(zhǎng)梅掠。 經(jīng)常有香客問(wèn)我,道長(zhǎng)店归,這世上最難降的妖魔是什么阎抒? 我笑而不...
    開封第一講書人閱讀 59,869評(píng)論 1 299
  • 正文 為了忘掉前任,我火速辦了婚禮消痛,結(jié)果婚禮上且叁,老公的妹妹穿的比我還像新娘。我一直安慰自己秩伞,他們只是感情好逞带,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,888評(píng)論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著纱新,像睡著了一般展氓。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上怒炸,一...
    開封第一講書人閱讀 52,475評(píng)論 1 312
  • 那天带饱,我揣著相機(jī)與錄音,去河邊找鬼阅羹。 笑死勺疼,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的捏鱼。 我是一名探鬼主播执庐,決...
    沈念sama閱讀 41,010評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼导梆!你這毒婦竟也來(lái)了轨淌?” 一聲冷哼從身側(cè)響起迂烁,我...
    開封第一講書人閱讀 39,924評(píng)論 0 277
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎递鹉,沒(méi)想到半個(gè)月后盟步,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,469評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡躏结,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,552評(píng)論 3 342
  • 正文 我和宋清朗相戀三年却盘,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片媳拴。...
    茶點(diǎn)故事閱讀 40,680評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡黄橘,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出屈溉,到底是詐尸還是另有隱情塞关,我是刑警寧澤,帶...
    沈念sama閱讀 36,362評(píng)論 5 351
  • 正文 年R本政府宣布子巾,位于F島的核電站帆赢,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏砰左。R本人自食惡果不足惜匿醒,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,037評(píng)論 3 335
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望缠导。 院中可真熱鬧廉羔,春花似錦、人聲如沸僻造。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)髓削。三九已至竹挡,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間立膛,已是汗流浹背揪罕。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評(píng)論 1 274
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留宝泵,地道東北人好啰。 一個(gè)月前我還...
    沈念sama閱讀 49,099評(píng)論 3 378
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像儿奶,于是被迫代替她去往敵國(guó)和親框往。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,691評(píng)論 2 361