欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS中使用Fastlane實現(xiàn)自動化打包和發(fā)布

 更新時間:2017年05月25日 09:42:49   作者:kiritoChen  
Fastlane是一套使用Ruby寫的自動化工具集,用于iOS和Android的自動化打包、發(fā)布等工作,可以節(jié)省大量的時間。下面給大家介紹ios fastlane 自動化打包和發(fā)布的安裝方法,需要的朋友參考下吧

簡介

Fastlane是一套使用Ruby寫的自動化工具集,用于iOS和Android的自動化打包、發(fā)布等工作,可以節(jié)省大量的時間。

Github:https://github.com/fastlane/fastlane

官網:https://fastlane.tools/

文檔:https://docs.fastlane.tools/

安裝

1、首先要安裝正確的 Ruby 版本。在終端窗口中用下列命令來確認:

ruby -v

2、然后檢查 Xcode 命令行工具是否安裝。在終端窗口中輸入命令:

xcode-select --install

如果未安裝,終端會開始安裝,如果報錯誤:command line tools are already installed, use "Software Update" to install updates.代表已經安裝。

3、以上依賴配置好之后就可以通過 rubygem 進行安裝了:

$ sudo gem install fastlane

安心等待一會,fastlane就安裝完成了。

初始化

打開終端,cd到你的工程目錄,然后執(zhí)行fastlane init:

$ cd to/your/ios/project 
$ fastlane init
[14:21:43]: Detected iOS/Mac project in current directory...
[14:21:43]: This setup will help you get up and running in no time.
[14:21:43]: fastlane will check what tools you're already using and set up
[14:21:43]: the tool automatically for you. Have fun! 
[14:21:43]: Created new folder './fastlane'.
[14:21:43]: $ xcodebuild -showBuildSettings -project ./xxx.xcodeproj
[14:21:48]: Your Apple ID (e.g. fastlane@krausefx.com): xxx@xxx.xom
[14:21:54]: Verifying that app is available on the Apple Developer Portal and iTunes Connect...
[14:21:54]: Starting login with user 'xxx@xxx.com'
+----------------+--------------------------------------+
|          Detected Values          |
+----------------+--------------------------------------+
| Apple ID    | xxx@xxx.com          |
| App Name    | xxx              |
| App Identifier | com.xxx.xxx        |
| Project    | /Users/lisong/Desktop/xxx/x |
|        | xx.xcodeproj           |
+----------------+--------------------------------------+
[14:22:06]: Please confirm the above values (y/n)
y
[14:22:09]: Created new file './fastlane/Appfile'. Edit it to manage your preferred app metadata information.
[14:22:09]: Loading up 'deliver', this might take a few seconds
[14:22:09]: Login to iTunes Connect (xxx@xxx.com)
[14:22:13]: Login successful
+-----------------------+------------------------+
|       deliver 2.30.1 Summary       |
+-----------------------+------------------------+
| screenshots_path   | ./fastlane/screenshots |
| metadata_path     | ./fastlane/metadata  |
| username       | xxx@xxx.com   |
| app_identifier    | com.xxx.xxx |
| edit_live       | false         |
| platform       | ios          |
| skip_binary_upload  | false         |
| skip_screenshots   | false         |
| skip_metadata     | false         |
| force         | false         |
| submit_for_review   | false         |
| automatic_release   | false         |
| dev_portal_team_id  | WKR87TTKML       |
| overwrite_screenshots | false         |
+-----------------------+------------------------+
[14:22:21]: Writing to 'fastlane/metadata/zh-Hans/description.txt'
...
[14:22:21]: Writing to 'fastlane/metadata/review_information/notes.txt'
[14:22:21]: Successfully created new configuration files.
[14:22:22]: Successfully downloaded large app icon
[14:22:22]: Downloading all existing screenshots...
[14:22:27]: Downloading existing screenshot '1_iphone4_1.1.jpg' for language 'zh-Hans'
···
[14:22:34]: Downloading existing screenshot '5_iphone6_5.5.jpg' for language 'zh-Hans'
[14:22:34]: Successfully downloaded all existing screenshots
[14:22:34]: Successfully created new Deliverfile at path 'fastlane/Deliverfile'
[14:22:34]: $ xcodebuild -list -project ./xxx.xcodeproj
[14:22:35]: 'snapshot' not enabled.
[14:22:35]: 'cocoapods' enabled.
[14:22:35]: 'carthage' not enabled.
[14:22:35]: Created new file './fastlane/Fastfile'. Edit it to manage your own deployment lanes.
[14:22:35]: fastlane will collect the number of errors for each action to detect integration issues
[14:22:35]: No sensitive/private information will be uploaded
[14:22:35]: Learn more at https://github.com/fastlane/fastlane#metrics
[14:22:35]: Successfully finished setting up fastlane

在 “Your Apple ID” 這一步輸入蘋果開發(fā)者賬號。在“Please confirm the above values”這一步,確認信息,沒問題輸入 y。然后,fastlane 會進行一系列的初始化操作,包括下載 App Store 上的元數據和截屏文件。

等待初始化完成之后,工程目錄下就多了一個 fastlane目錄,其內容如下:

咱們來看兩個主要的,Appfile和Fastfile。

Appfile

Appfile用來存放app_identifier,apple_id和team_id。 了解詳情,它的格式是這樣的:

app_identifier "com.xxx.xxx" # app的bundle identifier
apple_id "xxx@xxx.com" # 你的Apple ID
team_id "XXXXXXXXXX" # Team ID

你也可以為每個lane(后面會講到)提供不同的 app_identifier, apple_id 和 team_id,例如:

app_identifier "com.aaa.aaa"
apple_id "aaa@aaa.com"
team_id "AAAAAAAAAA"

for_lane :inhouse do
 app_identifier "com.bbb.bbb"
 apple_id "bbb@bbb.com"
 team_id "AAAAAAAAAA"
end

這里就是為Fastfile中定義的:inhouse設置單獨的信息。

Fastfile

Fastfile管理你所創(chuàng)建的 lane ,了解詳情。它的格式是這樣的:

···
# 自動更新fastlane 工具
# update_fastlane
#需要的fastlane的最小版本,在每次執(zhí)行之后會檢查是否有新版本,如果有會在最后末尾追加新版本提醒
fastlane_version "2.30.1"
#默認使用平臺是 ios,也就是說文件可以定義多個平臺
default_platform :ios
platform :ios do
 before_all do
  # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
  cocoapods
 end
 desc "Runs all the tests"
 lane :test do
  scan
 end
 desc "提交一個新的Beta版本到 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
  gym(scheme: "Docment") # Build your app - more options available
  pilot
  # sh "your_script.sh"
 end
 desc "部署一個新版本到App Store"
 lane :release do
  # match(type: "appstore")
  # snapshot
  gym(scheme: "Docment") # Build your app - more options available
  deliver(force: true)
  # frameit
 end
 # 你可以定義自己的lane
 #執(zhí)行l(wèi)ane成功后的回調
 after_all do |lane|
  # slack(
  #  message: "Successfully deployed new App Update."
  # )
 end
 # 如果流程發(fā)生異常會走這里并終止
 error do |lane, exception|
  # slack(
  #  message: exception.message,
  #  success: false
  # )
 end
end

我們也可以定義一個自己的lane:

 desc "企業(yè)版"
 lane :inHouse do
 gym(scheme: "XXX",
   export_method:"enterprise",
   output_directory "./build", # 打包后的 ipa 文件存放的目錄
   output_name "XXX" # ipa 文件名
  )
 end

其中一個lane就是一個任務,里面是一個個的action組成的工作流。

利用目前支持的工具可以做所有包含自動化和可持續(xù)化構建的每個環(huán)節(jié),例如:

scan 自動化測試工具,很好的封裝了 Unit Test

sigh 針對于 iOS 項目開發(fā)證書和 Provision file 的下載工具

match 同步團隊每個人的證書和 Provision file 的超贊工具

gym 針對于 iOS 編譯打包生成 ipa 文件

deliver 用于上傳應用的二進制代碼,應用截屏和元數據到 App Store

snapshot 可以自動化iOS應用在每個設備上的本地化截屏過程

執(zhí)行

定義完lane之后怎么執(zhí)行呢?打開終端,切換到項目的根目錄:執(zhí)行fastlane lane'name就可以了。成功之后會在相應的路徑下生成ipa文件,如果報錯的話就根據錯誤信息好好查看文檔。

其他

1、這里是官方提供的一些例子。

2、想了解fastlane命令的話可以執(zhí)行$ fastlane –help

3、查看可用任務的列表,可以執(zhí)行命令$ fastlane lanes

4、fastlane也提供了很多插件方便我們使用,例如pgyer(發(fā)布app到蒲公英)。我們也可以打完包直接傳到蒲公英上,具體的可以看蒲公英提供的文檔。

如果你感覺有些插件不符合自己的情況,你甚至可以自定義插件

5、多個 lane 的話實際上是可以相互調用的,這個其實特別實用。例如:

default_platform :ios
platform :ios do
 lane :prepare do
  cocoapods
  match
 end
 desc 'fastlane build'  'fastlane build type:adhoc'
 lane :build do |options|
  # 調用上面的 prepare 任務
  prepare
  case options[:type]
  when 'adhoc'
   adhoc
  else
   appstore
  end
 end
 lane : adhoc do
 ···
 end
 lane : appstore do
 ···
 end
end

我們可以在 Fastfile 文件中添加一個函數來設置version號和build號。

default_platform :ios

def prepare_version(options)
  increment_version_number(
    version_number: options[:version]
  )
  increment_build_number(
    build_number: options[:build]
  )
end

然后可以在一個lane中使用這個函數:

lane :appstore do |options|
  ···
  prepare_version(options)
  ···
end

然后執(zhí)行這個lane的時候:

$ fastlane appstore version:2.4.0 build:2.0

好啦,先說到這里吧,F(xiàn)astlane能做的事情還有很多,大家可以去好好看看文檔,研究一些高級的用法吧!

相關文章

  • IOS實現(xiàn)視頻動畫效果的啟動圖

    IOS實現(xiàn)視頻動畫效果的啟動圖

    這篇文章實現(xiàn)的是一個關于啟動頁或者引導頁的視頻動畫效果的實現(xiàn)過程,對于大家開發(fā)APP具有一定的參考借鑒價值,有需要的可以來看看。
    2016-09-09
  • iOS系統(tǒng)和微信中不支持audio自動播放問題的解決方法

    iOS系統(tǒng)和微信中不支持audio自動播放問題的解決方法

    最近在微信端開發(fā)H5的時候,audio標簽在蘋果機上無法進行自動播放,查找相關資料終于解決了,所以下面這篇文章主要給大家介紹了關于iOS系統(tǒng)和微信中不支持audio自動播放問題的解決方法,需要的朋友可以參考下。
    2017-09-09
  • iOS如何優(yōu)雅地消除應用角標詳解

    iOS如何優(yōu)雅地消除應用角標詳解

    關于應用角標相信大家應該都有所了解吧,這篇文章主要給大家介紹了關于iOS如何優(yōu)雅地消除應用角標的相關資料,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者們具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。
    2017-12-12
  • iOS實現(xiàn)簡單的二級菜單效果

    iOS實現(xiàn)簡單的二級菜單效果

    這篇文章給大家主要介紹的是利用iOS如何實現(xiàn)簡單的菜單效果,文中給出了詳細的示例代碼,而且實現(xiàn)的比較簡單,適合新人學習使用。感興趣的朋友們可以參考借鑒,下面來一起看看吧。
    2016-10-10
  • iOS 點擊圖片放大效果的實現(xiàn)

    iOS 點擊圖片放大效果的實現(xiàn)

    本篇文章主要介紹了iOS 點擊圖片放大效果的實現(xiàn),這種效果一般在微博,微信朋友圈中比較常見,有興趣的可以了解一下。
    2017-01-01
  • IOS開發(fā) UIAlertController詳解及實例代碼

    IOS開發(fā) UIAlertController詳解及實例代碼

    這篇文章主要介紹了 IOS開發(fā) UIAlertController詳解及實例代碼的相關資料,需要的朋友可以參考下
    2016-12-12
  • iOS 泛型中nullable、null resettable、null kindof 用法詳解

    iOS 泛型中nullable、null resettable、null kindof 用法詳解

    這篇文章主要介紹了iOS 泛型中nullable、null resettable、null kindof 用法詳解的相關資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-09-09
  • iOS用AutoLayout實現(xiàn)分頁滾動功能

    iOS用AutoLayout實現(xiàn)分頁滾動功能

    這篇文章主要給大家介紹了關于iOS用AutoLayout實現(xiàn)分頁滾動功能的相關資料,文中通過示例代碼介紹的非常詳細,對各位iOS開發(fā)者們具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-06-06
  • iOS測試手機APP的方法匯總:真機運行,打ipa包,testFlighe,蒲公英

    iOS測試手機APP的方法匯總:真機運行,打ipa包,testFlighe,蒲公英

    這篇文章主要介紹了iOS通常測試手機APP的四種方法:真機運行,打ipa包,(testFlighe)郵件,蒲公英測試。需要的朋友可以參考下
    2022-12-12
  • iOS實現(xiàn)微信朋友圈視頻截取功能

    iOS實現(xiàn)微信朋友圈視頻截取功能

    這篇文章主要介紹了iOS實現(xiàn)微信朋友圈視頻截取功能,微信使用非常普遍,功能也很強大,不知道大家對微信朋友圈視頻截取功能有沒有了解,下面腳本之家小編給大家?guī)碓斀饨榻B,感興趣的朋友一起看看吧
    2018-07-07

最新評論