今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

iOS 自動パッケージング

iOS 自動パッケージング#

FastLane を使用したパッケージング#

fastlane のインストール#

  • HomeBrew を使用してインストール
    brew install fastlane

  • Bundler を使用してインストール

    1. bundler をインストール
    2. プロジェクトのルートディレクトリに./Gemfile ファイルを作成し、内容を編集

// bundlerをインストール
$ gem install bundler


// プロジェクトのルートディレクトリに./Gemfileファイルを作成し、内容を編集
source "https://rubygems.org"
gem "fastlane"

Gemfile ファイルを編集:


source "https://rubygems.org"
gem "fastlane", "2.180.1"
# Cocoapodsを使用する場合は、以下の行を追加する必要があります
gem "cocoapods"

  • ruby gems を使用してインストール
sudo gem install fastlane

fastlane のインストールが成功したら、バージョン管理とパッケージング成功後に対応するサードパーティプラットフォームにアップロードするための 2 つのプラグインをインストールします。

// fastlaneプラグインを追加
// versioningの使用参考:https://github.com/SiarheiFedartsou/fastlane-plugin-versioning、バージョン番号の取得と変更に使用
// firimはfirプラットフォームプラグイン

fastlane add_plugin versioning
fastlane add_plugin fir_cli # https://github.com/FIRHQ/fastlane-plugin-fir_cli


// pgyerは蒲公英プラットフォーム
// fastlane add_plugin pgyer

fastlane の内容編集#

fir プラットフォームの firim 関連パラメータの参考:伝送門、最小限必要な firim_api_token パラメータは、自分が登録した firim から取得できます。または、以下のパラメータを設定できます。

  • firim_api_token
  • app_name
  • app_desc
  • app_passwd
  • app_version
  • app_build_version
  • app_changelog
  • など

Fastfile を編集し、Action を定義します。名前は TestFir で、出力パッケージ名を(バージョン番号 + 時間)に指定し、パッケージング後のパッケージのディレクトリを./build ディレクトリにし、パッケージングが完了したら fir にアップロードします。以下のようにします。


default_platform(:ios)

platform :ios do
  desc "レーンの説明"

  lane :TestFir do
    time = Time.new.strftime("%Y%m%d%H%M") # 時間形式を取得、形式の参考:https://www.runoob.com/python/att-time-strftime.html
    # verion = get_version_number_from_list() # バージョン番号を取得

    version = get_version_number_from_xcodeproj(build_configuration_name: 'Release') # 参考GitHubリンク:https://github.com/SiarheiFedartsou/fastlane-plugin-versioning

    ipaName = "Release_#{version}_#time.ipa" # ipaパッケージの名前形式を生成

    gym(
      clean: true, # パッケージング前にプロジェクトをクリーン
      silent: true, # 不必要な情報を隠す
      scheme: "Your Scheme Name", # プロジェクトのscheme名を指定
      export_method: "ad-hoc", # パッケージングのタイプ:ad-hoc, enterprise, app-store, development
      configuration: "Release", # scheme:デフォルトはRelease、Debugもあり
      output_name: "#{ipaName}", # 出力の名前
      output_directory: "./build" # 出力の場所
    )
    # 自分のfirアカウント、設定内容の参考:https://github.com/FIRHQ/fastlane-plugin-fir_cli
    fir_cli api_token: "xxx",  changelog: "My First Fir Upload"
    # 蒲公英の設定 自分のapi_keyとuser_keyに置き換え
    # pgyer(api_key: "******", user_key: "******",update_description: options[:update_info])
  end

end

使用時は、コマンドラインで fastlane TestFir と入力します。

fastlane TestFir

コマンドを実行する際に外部からパラメータを渡したい場合は、以下の方法で使用できます。do の後に | options | を追加し、使用時に options [] のように外部から渡された値を取得します。

lane :ActionName do |options|
    gym(
      configuration: options[:configuration],#環境
      )
    
    # 自分のfirアカウント
    fir_cli api_token: "xxx",  changelog: options[:changelog]
  end

外部から呼び出す方法は以下の通りです:

fastlane ActionName configuration:"adhoc" changelog:"first submit"

Jenkins を使用したパッケージング、未完待続#

参考#

iOS の 自動パッケージング fastlane + fir + pgy 【進階使用】

読み込み中...
文章は、創作者によって署名され、ブロックチェーンに安全に保存されています。