2
2

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 3 years have passed since last update.

Fastlaneを使って、Firebase App Distributionを自動化する

Last updated at Posted at 2020-07-29

Fabric終了に伴い、Firebase App Distributionを用いてアプリを配布しているプロジェクトは数多くあると思います。
手動で配布することもできるのですが、その場合、

  1. ipaファイル作成
  2. Firebaseコンソールに移動
  3. ファイルのアップロード
  4. テスターの指定
    などと毎回同じ作業をするのは面倒です。

そこで個人プロジェクトでこちらの作業をfastlaneコマンド一発でできるようにしたので、その時の手順を記します。

今回解説するのは

  • fastlaneのセットアップ
  • fastlaneによるipa作成、アップロード方法
    です。

Installing fastlane

まずはHomebrew経由でfastlaneをインストール

brew install fastlane

プロジェクトのルートディレクトリで下記コマンドを実行。
fastfileが作成され、こちらに後ほど配布するためのコードを記述します。

fastlane init

プラグインを追加

fastlane add_plugin firebase_app_distribution

ローカルマシンでFirebaseにログインできるようにする

ドキュメントに従います

Firebase CLIをダウンロード

curl -sL https://firebase.tools | bash

以下コマンドで確認

firebase login

firebase-toolsのインストール

まずはNode.jsをダウンロードします。
https://nodejs.org/ja/download/

プロジェクトのルートディレクトリで以下コマンドを入力。package.jsonが作成されます。

npm init

これでfirebase-toolsをインストールすることができます。

npm install firebase-tools

以下のパスはgitignoreに追記。

node_modules/

fastfileへの記述

platform :ios do
  desc "deploy DEV on Firebase App Distribution"
  lane :distribution do
    # .ipaファイルの作成
    gym(
      workspace: "hoge.xcworkspace",
      scheme: "hoge",
      export_method: "ad-hoc",
      export_options: {
        method: 'ad-hoc',
        teamID: 'hoge',
        provisioningProfiles: {
          'bundle identifier name' => 'provisioning profile name'
        }
      }
    )

    # firebase app distributionに.ipaアップロード
    firebase_app_distribution(
      app: "1:1234567890:ios:0a1b2c3d4e5f67890",
      testers: "emailadress@gmail.com, emailadress2@gmail.com",
      release_notes: "hoge",
      firebase_cli_path: "node_modules/.bin/firebase"
    )
  end
end

firebase_app_distributionについて

appの引数にはFirebaseのプロジェクト設定画面にあるアプリIDを指定。(プロジェクトIDじゃないよ)

Provisioning Profileの作成

Dev環境かつAutoでやってたので、appleのdeveloperサイトから手動で作成する必要があった。
Dev環境用のProvisioning Profileを作成し、その名前をFastfileに記述。
ダウンロードしたら、起動して、キーチェーンに登録までする。

実行

fastlane distributionで実行できます。
実行したら、Firebaseコンソール -> プロジェクト -> App Distributionで新たなバイナリーができているかを確認しましょう。

参考

https://firebase.google.com/docs/app-distribution/ios/distribute-fastlane?hl=ja
https://qiita.com/fuwamaki/items/a9745e1242e24430eb4c#fastlane%E3%82%92%E7%94%A8%E3%81%84%E3%81%9Ffirebase-app-distribution%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89%E6%96%B9%E6%B3%95

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?