Distribute iOS apps to testers using fastlane

You can distribute builds to testers using fastlane, an open source platform that automates building and releasing iOS and Android apps. It follows simple instructions defined in a Fastfile. After you set up fastlane and your Fastfile, you can integrate App Distribution with your fastlane configuration.

Step 1. Set up fastlane

  1. Install and set up fastlane.

  2. To add App Distribution to your fastlane configuration, run the following command from the root of your iOS project:

    fastlane add_plugin firebase_app_distribution

    If the command prompts you with an option, select Option 3: RubyGems.org.

Step 2. Authenticate with Firebase

Before you can use the Fastlane plugin, you must first authenticate with your Firebase project. There are three ways to achieve this:

Step 3. Set up your Fastfile and distribute your app

  1. In a ./fastlane/Fastfile lane, add a firebase_app_distribution block. Use the following parameters to configure the distribution:
    firebase_app_distribution parameters
    app

    Required only if your app does not contain a Firebase config file (GoogleService-Info.plist): Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page.

    app: "1:1234567890:ios:0a1b2c3d4e5f67890"
    googleservice_info_plist_path

    The path to your GoogleService-Info.plist file, relative to the archived product path. Set to GoogleService-Info.plist by default.

    The file is used to get your app's Firebase App ID if the app parameter is unspecified.

    firebase_cli_token

    A refresh token that's printed when you run the plugin's login action (see Authenticate using a Google account, above), or when you authenticate your CI environment with the Firebase CLI (read Use the CLI with CI systems for more information).

    service_credentials_file

    The path to your Google service account json file. See above for how to authenticate using service account credentials.

    ipa_path

    Replaces apk_path (deprecated). Absolute path to the IPA file you want to upload. If unspecified, fastlane determines the file's location from the lane in which the file was generated.

    release_notes
    release_notes_file

    Release notes for this build.

    You can either specify the release notes directly:

    release_notes: "Text of release notes"

    Or, specify the path to a plain text file:

    release_notes_file: "/path/to/release-notes.txt"
    testers
    testers_file

    The email addresses of the testers you want to invite.

    You can specify the testers as a comma-separated list of email addresses:

    testers: "ali@example.com, bri@example.com, cal@example.com"

    Or, you can specify the path to a plain text file containing a comma-separated list of email addresses:

    testers_file: "/path/to/testers.txt"
    groups
    groups_file

    The tester groups you want to invite (refer to Manage testers). Groups are specified using group aliases, which you can look up in the Firebase console.

    You can specify the groups as a comma-separated list:

    groups: "qa-team, trusted-testers"

    Or, you can specify the path to a plain text file containing a comma-separated list of group names:

    groups_file: "/path/to/groups.txt"
    debug

    A boolean flag. You can set this to true to print verbose debug output.

For example:

platform :ios do
    desc "My awesome app"
    lane :distribute do
        build_ios_app(...)
        # build_ios_app is a built-in fastlane action.

        firebase_app_distribution(
            app: "1:123456789:ios:abcd1234",
            testers: "tester1@company.com, tester2@company.com",
            release_notes: "Lots of amazing new features to test out!"
        )

    end
end

To make the build available to testers, run your lane:

fastlane <lane>

After you distribute your build, it is available in the App Distribution dashboard of the Firebase console for 150 days. When the build is 30 days from expiring, an expiration notice appears in the console and in the tester's list of builds on their test device.

Testers who weren't previously invited to test the app receive email invitations to get started. Existing testers receive email notifications that a new build is ready to test. To learn how to install the test app, see tester set up guide. You can monitor the status of each tester to determine whether they accepted the invitation and whether they downloaded the app in the Firebase console.

(Optional) To automatically increment your build number every time you create a new release in App Distribution, you can use the firebase_app_distribution_get_latest_release action and the increment_build_number action. The following code provides an example of how to automatically increment your build number:

lane :increment_version do
  latest_release = firebase_app_distribution_get_latest_release(
    app: "<your Firebase app ID>"
  )
  increment_build_number({ build_number: latest_release[:buildVersion].to_i + 1 })
end

To learn more about this fastlane plugin feature, see Get information about your app's latest release.

Step 4 (Optional). Manage testers for the distribution

You can add and remove testers from your app release using your Fastfile file or by directly running fastlane actions. Running actions directly overrides the values set in your Fastfile.

Once a tester is added to your Firebase project, you can add them to individual releases. Testers who are removed from your Firebase project no longer have access to releases in your project, but they might retain access to your releases for a window of time.

Use Fastfile

# Use lanes to add or remove testers from an app release.
lane(:add_testers) do
  firebase_app_distribution_add_testers(
    emails: "foo@google.com,bar@google.com"
    # or file: "/path/to/testers.txt"
  )
end

lane(:remove_testers) do
  firebase_app_distribution_remove_testers(
    emails: "foo@google.com,bar@google.com"
    # or file: "/path/to/testers.txt"
  )
end
# Add or remove testers with the terminal
$ fastlane add_testers
$ fastlane remove_testers

Run fastlane actions

fastlane run firebase_app_distribution_add_testers emails:"foo@google.com,bar@google.com"

fastlane run firebase_app_distribution_remove_testers emails:"foo@google.com,bar@google.com"

You can also specify testers using --file="/path/to/testers.txt instead of --emails.

The firebase_app_distribution_add_testers and firebase_app_distribution_remove_testers tasks also accept the following arguments:

  • project_name: Your Firebase project number.
  • service_credentials_file: The path to your Google service credentials file.
  • firebase_cli_token: Auth token for Firebase CLI.

The service_credentials_file and the firebase_cli_token are the same arguments used by the upload action.

Step 5 (Optional). Get information about your app's latest release

You can use the firebase_app_distribution_get_latest_release action to fetch information about your app's latest release in App Distribution, including app version information, release notes, and creation time. Use cases include automatically increasing the version and carrying over the release notes from the previous release.

The return value of the action is a hash representing the latest release. This hash is also available using lane_context[SharedValues::FIREBASE_APP_DISTRO_LATEST_RELEASE]. For more information about the available fields in this hash, see the REST API documentation.

Parameters

firebase_app_distribution_get_latest_release parameters
app

Required only if your app does not contain a Firebase config file (GoogleService-Info.plist): Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page.

app: "1:1234567890:ios:0a1b2c3d4e5f67890"
googleservice_info_plist_path

The path to your GoogleService-Info.plist file, relative to the archived product path. Set to GoogleService-Info.plist by default.

The file is used to get your app's Firebase App ID if the app parameter is unspecified.

firebase_cli_token

A refresh token that's printed when you run the plugin's login action (see Authenticate using a Google account, above), or when you authenticate your CI environment with the Firebase CLI (read Use the CLI with CI systems for more information).

service_credentials_file

The path to your Google service account json file. See above for how to authenticate using service account credentials.

debug

A boolean flag. You can set this to true to print verbose debug output.