関連資料
- 公式ドキュメント
- iOSアプリのリリースフロー自動化ツールfastlaneの導入
- これから始めるfastlane
- iOSアプリの継続的デリバリーに便利なfastlaneのご紹介
- fastlane で build/version number をインクリメントする
導入
fastlane インストール
$ gem install fastlane
関連資料には、上記のコードが書いてあるものが多かったが、エラーがでた。
下記のようにすると成功した。(公式ドキュメントと同じ)
$ sudo gem install fastlane --verbose
Xcode command line toolsをインストール
$ xcode-select --install
自分のアプリのプロジェクトのディレクトリに移動。
$ fastlane init
色々、質問されるので逐次回答する。
iOSアプリのリリースフロー自動化ツールfastlaneの導入のセットアップを参照。
iTunesConnectにアップロード
gymでipaファイルを作成
    ↓
deliverでアップロード
自分のアプリのディレクトリ内にfastlaneディレクトリが生成されている。
fastlaneに移動し、Deliverfileを開く。
以下をDeliverfileに記入。
###################### More Options ######################
# If you want to have even more control, check out the documentation
# https://github.com/fastlane/fastlane/blob/master/deliver/Deliverfile.md
###################### Automatically generated ######################
# Feel free to remove the following line if you use fastlane (which you should)
app_identifier "com.*****.******" # The bundle identifier of your app
username "*******@gmail.com" # your Apple ID user
# アプリ名称
name({
  'ja' => "AppName"
})
# アプリバージョン
app_version "1.0"
#######
# 設定値#
#######
# そのまま申請する場合はtrue しない場合はfalse
submit_for_review false
# HTMLで内容確認を行う場合はfalse 確認を行わずアップロードを行う場合はtrue
force false
# スクリーンショットのアップロードをスキップする場合はtrue
skip_screenshots true
# メタデータのアップロードをスキップする場合はtrue
skip_metadata false
# バイナリーデータ(ipa,pkg)のアップロードをスキップする場合はtrue
skip_binary_upload false
Fastfileを開く。
以下をFastfileに記入。
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/docs
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# If you want to automatically update fastlane if a new version is available:
# update_fastlane
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "1.80.0"
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 "Submit a new Beta Build to 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
    cert
    sigh(force: true)
    gym(
      workspace: "******.xcworkspace",
      configuration: "Release",
      scheme: "********",
    ) 
    pilot
    # sh "your_script.sh"
    # You can also use other beta testing services here (run `fastlane actions`)
  end
  desc "Deploy a new version to the App Store"
  lane :appstore do
    # match(type: "appstore")
    # snapshot
    cert
    sigh(force: true)
    gym(
      workspace: "******.xcworkspace",
      configuration: "Release",
      scheme: "********",
    ) 
    deliver(force: true)
    # frameit
  end
  # You can define as many lanes as you want
  after_all do |lane|
    # This block is called, only if the executed lane was successful
    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end
  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end
$ fastlane appstore
でipaファイルを作成し、iTunesConnectにアップロードするのを自動でしてくれる。
AppStoreにアップロードするときの処理は、lane :appstore内に書く。
最初、appstore内にgymとdeliverのみ書いていると、証明書関係のエラーが発生し困った。
そこで、gymの前に
cert
sigh(force: true)
を記入するとうまくipaファイルを作成できた。