今是昨非

今是昨非

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

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 を編集し、TestFir という名前のアクションを定義します。出力パッケージ名を (バージョン番号 + 時間) に指定し、パッケージ後のディレクトリを./build ディレクトリに設定し、パッケージが完了したら fir にアップロードします。以下のようになります


default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"

  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 【進階使用】

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