fastlane 持續集成第一篇

最牛X的iOS、安卓自動打包管理工具,沒有之一,The easiest way to build and release mobile apps.ios

安裝前的準備工做

1.Ruby環境api

2.Xcoderuby

安裝fastlanebash

# Using RubyGemssudo gem install fastlane -NV
//或者
# Alternatively using Homebrewbrew cask install fastlane
複製代碼

使用fastlaneapp

1. cd + 項目目錄 ide

2. fastlane init ,個人是以前安裝過,須要升級

四個選項: 1.自動截屏 2.自動發佈TestFlight 3.自動發佈AppStore 4.手動設置 咱們測試 選擇4,此時項目中會出現一個fastlane文件夾和兩個文件如圖: 函數

Appfile

# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app
# apple_id("[[APPLE_ID]]") # Your Apple email address
# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile
複製代碼

Fastfile工具

# 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

複製代碼

這些是Ruby代碼,和CocoaPods內代碼相似:測試

  1. customers_lane是函數名稱,打包的執行命令的時候使用
  2. actions是擴展,能夠本身寫插件、命令等操做用於打包

寫命令

default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
  lane :veronica do
    version = get_version_number
    ipaName = "veronica_#{version}.ipa"
    gym(
    scheme:"veronica",
    export_method:"development",
    configuration:"Release",
    output_name:"#{ipaName}",
    output_directory:"./build"
    )
  end
end
複製代碼

開始打包 ui

打包結束 用時三分鐘
打包成功

上傳到fir.im

  1. cd到項目目錄下,安裝fir的插件,執行命令

    fastlane add_plugin firim
    複製代碼
  2. 編寫Fastfile文件,添加firim相關代碼

    default_platform(:ios)
    
    platform :ios do
      desc "Description of what the lane does"
      lane :veronica do
        version = get_version_number
        ipaName = "veronica_#{version}.ipa"
        firim_api_token="*********************"
        gym(
        scheme:"veronica",
        export_method:"development",
        configuration:"Release",
        output_name:"#{ipaName}",
        output_directory:"./build"
        )
        firim(firim_api_token:"#{firim_api_token}")
      end
    end
    複製代碼
  3. cd到項目目錄下,執行命令:

    fastlane veronica
    複製代碼
  4. 打包上傳成功

未完待續

參考連接:

  1. fastlane官網
  2. iOS使用fastlane自動化打包
相關文章
相關標籤/搜索