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

fastlane自動(dòng)化打包iOS APP過(guò)程示例

 更新時(shí)間:2022年07月20日 15:04:54   作者:QiShare  
這篇文章主要為大家介紹了fastlane自動(dòng)化打包iOS APP的過(guò)程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

概述

APP自動(dòng)化打包常見(jiàn)的主流工具有Jenkins、fastlaneJenkins功能強(qiáng)大,但是需要的配置也比較多,團(tuán)隊(duì)較大的可以優(yōu)先考慮,fastlane是用Ruby語(yǔ)言編寫的一套自動(dòng)化工具集,比較輕便,配置簡(jiǎn)單,使用起來(lái)也很方便。本文會(huì)詳細(xì)的介紹fastlane從安裝到上傳APP到蒲公英的整個(gè)流程。

fastlane的安裝

第一步

因?yàn)閒astlane是用Ruby語(yǔ)言編寫的工具,所以必須保證已經(jīng)配置好了Ruby開(kāi)發(fā)環(huán)境??梢允褂萌缦旅钚胁榭词欠癜惭b了Ruby:

ruby -v

如果有以下提示說(shuō)明,你已經(jīng)安裝了Ruby:

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin21]

如果沒(méi)有安裝需要先安裝ruby,本文對(duì)安裝ruby不作教程說(shuō)明。

第二步

安裝Xcode命令行工具

xcode-select --install

如果沒(méi)有安裝,命令會(huì)有提示框,根據(jù)提示一步一步安裝即可。 如果出現(xiàn)以下命令提示,說(shuō)明已經(jīng)安裝成功:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

第三步:

Ruby和Xcode環(huán)境都配置好之后,執(zhí)行以下命令來(lái)安裝fastlane:

sudo gem install -n /usr/local/bin fastlane

安裝完成之后,輸入以下命令查看是否安裝成功:

fastlane --version

出現(xiàn)以下提示說(shuō)明你已經(jīng)安裝成功了:

fastlane installation at path:
/Users/xxxxxx/.rvm/gems/ruby-2.7.0/gems/fastlane-2.206.1/bin/fastlane
-----------------------------
[?] ?? 
fastlane 2.206.1

fastlane的配置

到你的iOS項(xiàng)目下,執(zhí)行初始化命令:

fastlane init

命令執(zhí)行完成之后會(huì)給出我們?nèi)缦聨讉€(gè)提示:

[?] ?? 
[?] Looking for iOS and Android projects in current directory...
[16:54:04]: Created new folder './fastlane'.
[16:54:04]: Detected an iOS/macOS project in the current directory: 'xxxx.xcworkspace'
[16:54:04]: -----------------------------
[16:54:04]: --- Welcome to fastlane ?? ---
[16:54:04]: -----------------------------
[16:54:04]: fastlane can help you with all kinds of automation for your mobile app
[16:54:04]: We recommend automating one task first, and then gradually automating more over time
[16:54:04]: 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í)行到最后有What would you like to use fastlane for?提示,此時(shí)fastlane列出幾個(gè)選項(xiàng),需要我們告訴它使用fastlane需要執(zhí)行哪種操作:

  • 第一種獲取App Store的App預(yù)覽照片。
  • 第二種打包上傳至TestFlight工具上。
  • 第三種打包上傳到App Store。
  • 第四種自定義打包方式。

以上四種方式根據(jù)自己的需要自行選擇,本文主要介紹打包上傳至第三方平臺(tái),所以選擇4自定義打包方式。選擇完成之后,fastlane會(huì)在我們項(xiàng)目中創(chuàng)建fastlane文件

[16:54:32]: ------------------------------------------------------------
[16:54:32]: --- Setting up fastlane so you can manually configure it ---
[16:54:32]: ------------------------------------------------------------
[16:54:32]: Installing dependencies for you...
[16:54:32]: $ bundle update
[16:54:40]: --------------------------------------------------------
[16:54:40]: --- ?  Successfully generated fastlane configuration ---
[16:54:40]: --------------------------------------------------------
[16:54:40]: Generated Fastfile at path `./fastlane/Fastfile`
[16:54:40]: Generated Appfile at path `./fastlane/Appfile`
[16:54:40]: Gemfile and Gemfile.lock at path `Gemfile`
[16:54:40]: Please check the newly generated configuration files into git along with your project
[16:54:40]: This way everyone in your team can benefit from your fastlane setup
[16:54:40]: Continue by pressing Enter ?

創(chuàng)建好fastlane文件夾之后,Appfile是編輯我們相關(guān)App和開(kāi)發(fā)者賬號(hào)信息的,一般不需要我們?nèi)ナ謩?dòng)修改。Fastfile是我們對(duì)自動(dòng)打包這個(gè)過(guò)程的完整配置,默認(rèn)的Fastfile文件內(nèi)容如下:

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
  desc "Description of what the lane does"
  lane :custom_lane do
    # add actions here: https://docs.fastlane.tools/actions
  end
end

打包并自動(dòng)上傳 App 到蒲公英

安裝蒲公英的 fastlane 插件

fastlane add_plugin pgyer

編輯Fastlane 的配置文件 fastlane/Fastfile

lane :develop do
   target = "demo"
   configuration = "Debug"
   gym(scheme: target, configuration: configuration, export_method:"development")
   pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e")
end

以下是蒲公英平臺(tái)的說(shuō)明:

  • 以上的 api_keyuser_key,請(qǐng)開(kāi)發(fā)者在自己賬號(hào)下的 應(yīng)用管理 - App概述 - API 中可以找到,并替換到以上相應(yīng)的位置。
  • 在 Xcode 8.3 和 Xcode 8.3 以后的版本中,對(duì)于 build_appexport_method 的值,需要根據(jù)開(kāi)發(fā)者的打包類型進(jìn)行設(shè)置,可選的值有:app-store、ad-hocdevelopment、enterprise。對(duì)于 Xcode 8.3 以下的版本,則不需要設(shè)置 export_method。

經(jīng)過(guò)以上配置后,就可以使用 Fastlane 來(lái)打包 App,并自動(dòng)上傳到蒲公英了。在終端下,定位到項(xiàng)目所在目錄,輸入以下命令即可:

fastlane develop

在成功的情況下,可以看到類似下面的信息:

[18:37:22]: Successfully exported and compressed dSYM file
[18:37:22]: Successfully exported and signed the ipa file:
[18:37:22]: /Users/xxx/Documents/workCode/xxxxx.ipa
[18:37:22]: -------------------
[18:37:22]: --- Step: pgyer ---
[18:37:22]: -------------------
[18:37:22]: The pgyer plugin is working.
[18:37:22]: build_file: /Users/dddd/Documents/workCode/xxxx.ipa
[18:37:22]: Start upload /Users/dddd/Documents/workCode/xxx.ipa to pgyer...
[18:37:43]: Upload success. Visit this URL to see: https://www.pgyer.com/xxxxx

+------+------------------+-------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
| 2    | gym              | 61          |
| 3    | pgyer            | 20          |
+------+------------------+-------------+

[18:37:43]: fastlane.tools finished successfully ??

  • 設(shè)置一個(gè)版本更新時(shí)的描述信息:
lane :develop do
  build_app(export_method: "development")
  pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", update_description: "update by fastlane")
end

打包上傳到Testflight

在Fastfile文件中加入下面命令:

desc "打包上傳到Testflight"
  lane :beta do
    # add actions here: https://docs.fastlane.tools/actions
   target = "demo"
   configuration = "Release"
   gym(scheme: target, configuration: configuration, export_method:"app-store")
   upload_to_testflight(
 	    username: "xxxx@dd.com",
            app_identifier: "com.xxxx",
          )

在命令行輸入:

fastlane beta

打包上傳的過(guò)程中會(huì)讓你輸入蘋果賬號(hào)的密碼,并且有可能會(huì)報(bào)下面的錯(cuò):

[00:20:28]: Login successful
[00:20:31]: Ready to upload new build to TestFlight (App: fffff)...
[00:20:40]: Transporter transfer failed.
[00:20:40]: 
[00:20:40]: Please sign in with an app-specific password. You can create one at appleid.apple.com. (-22910)
[00:20:41]: 
[00:20:41]: Your account has 2 step verification enabled
[00:20:41]: Please go to https://appleid.apple.com/account/manage
[00:20:41]: and generate an application specific password for
[00:20:41]: the iTunes Transporter, which is used to upload builds
[00:20:41]: 
[00:20:41]: To set the application specific password on a CI machine using
[00:20:41]: an environment variable, you can set the
[00:20:41]: FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD variable

這是因?yàn)槟愕腁PPLE賬號(hào)開(kāi)啟了雙重驗(yàn)證,注意這句提示Please sign in with an app-specific password用app專用密碼登錄,提示你創(chuàng)建一個(gè)app專用密碼登錄Transporter,關(guān)于怎么創(chuàng)建app專用密碼本人不做講解,可以自行百度或者谷歌,使用app專用賬號(hào)即可解決此問(wèn)題。

以上就是fastlane自動(dòng)化打包iOS APP過(guò)程示例的詳細(xì)內(nèi)容,更多關(guān)于fastlane打包iOS APP的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論