1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Fabric beta + fastlane + slackでStockey Adhocを自動化

Last updated at Posted at 2019-02-24

課題

プライベートでStockeyというiOSアプリを開発しており、Adhoc版ipaのビルドから配布までをBitriseを使っていました。
しかし、機能が増えるに従ってビルド時間が長くなり、無料の範囲内のワークフロー10分制限を超えるようになってしまい、最近はテストフライトを使っております。
テストフライトでは、本番アプリに上書き・配布までに時間が掛かるなどの問題があるため、他の方法を調べたところ、Fabricにipaの配布を行う機能があることを知りました。ただこれだけだと何かと手間なため、最近流行りのfastlaneを使って、ビルドからslackへの通知まで1コマンドで実行できるように対応しました。

セットアップ手順

fastlaneのインストール

$ sudo gem install fastlane

私のPCではsudoをつけないとパーミッションが足りないと怒られたのでつけてます。
これでインストールできたバージョンが2.116.0で、最新は2.116.1でした。
新規インストールでしたので、2.116.1までアップデートします。

$ sudo gem update fastlane

これで完了

fastlaneの初期セットアップ

$ cd <Xcodeのプロジェクトファイルがあるフォルダパス>
$ fastlane init

1〜4までの選択肢が表示され、4を選択しました。
4. 🛠 Manual setup - manually setup your project to automate your tasks

あとはなにか聞かれるたびに、Enterで完了。
フォルダ内にfastlaneフォルダや設定ファイル類が生成されます。

./fastlane/Fastfileの編集

Stockey用にしてありますので、もし参考にされる方がおりましたら、各プロジェクト用に最適な設定に変更してください。
※見せられないところは<コメント>にしてあります。

default_platform(:ios)

platform :ios do
  desc "<任意の説明文>"
  lane :up_adhoc_dev do

    scheme = "StockeyDev"
    info_plist_path = "./Stockey/Info-Dev.plist"
    version_number = get_info_plist_value(
        path: info_plist_path,
        key: "CFBundleShortVersionString"
    )
    build_number = get_info_plist_value(
        path: info_plist_path,
        key: "CFBundleVersion"
    )

    xcode_select("/Applications/Xcode.app")
 
    gym(
      configuration: "Release",
      scheme: scheme,
      export_method: "ad-hoc",
      output_directory: "./build/ipa/" + Time.new.strftime("%Y/%m/%d/%H%M"),
      output_name: "StockeyDev.ipa",
      include_bitcode: false,
      clean: true,
      export_options: {
        compileBitcode: false,
        uploadBitcode: false
      }
    )
 
    crashlytics(
      crashlytics_path: "./Vendor/Fabric/Crashlytics.framework/submit",
      api_token: "<APIトークンを設定>",
      build_secret: "<シークレットキーを設定>",
      notes: "<任意の説明>",
      groups: "<Fabricで設定したテスターグループ名を設定>"
    )
 
    slack(
      message: "インストールページ v" + version_number + "(" + build_number + ")\n" + "<Fabricでのipa配信ページのURL>",
      slack_url: "<slackのURLを設定>"
    )
  end
end

実行

cd <Xcodeのプロジェクトファイルがあるフォルダパス>
bundle exec fastlane up_adhoc_dev

参考文献

[iOS] アプリをAd Hoc配布可能にする手順について
[iOS] fastlaneを導入する手順について

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?