Publishing Flutter Builds with Fastlane and Firebase App Distribution 🚀

Aayush Kedawat
3 min readApr 18, 2024

--

Fastlane is a powerful tool that streamlines the mobile app development process, including automating publishing for Flutter apps. This guide will walk you through setting up Fastlane for publishing your Flutter builds to testers using Firebase App Distribution.

Prerequisites

  • A Flutter project
  • Fastlane installed: gem install fastlane (or brew install fastlane on macOS)

Setting Up Fastlane

  1. Initialize the Fastlane projects for each platform.

Android setup -

  • In your [project]/android directory, run fastlane init.
  • Enter package name
  • Enter JSON secret file path (leave blank for now)
  • Continue by pressing the enter

iOS setup

  • In your [project]/ios directory, run fastlane init.
  • Select Manual setup — manually setup your projects to automate tasks in What would you like to use Fastlane for?
  • Continue by pressing the enter

2. Edit the Appfiles to ensure they have adequate metadata for your app.

a. Verify Android Package Name Consistency:

  • Open your project’s AndroidManifest.xml file.
  • Locate the package attribute within the <manifest> tag. This value represents your app's package name on Android.
  • Now, navigate to your Fastlane configuration file (Appfile) typically located in the android/fastlane directory.
  • Find the package_name property within the fastlane block. Ensure this value exactly matches the package name you found in the AndroidManifest.xml file. If there's a mismatch, correct it in the Appfile.

b. Confirm iOS Bundle Identifier and Account Details:

  • Open your project’s Info.plist file (usually found in the iOS root directory).
  • Locate the key named Bundle identifier. This value represents your app's unique identifier on iOS.
  • Go to your Fastlane configuration file (Appfile), typically situated in the ios/fastlane directory.
  • Find the app_identifier property within the fastlane block. Verify that it precisely matches the bundle identifier you retrieved from Info.plist. If there's a discrepancy, update the Appfile.

3. Authenticate with Firebase

  • Install Firebase tools CLI
npm install -g firebase-tools
  • Run the following command and authenticate CLI with the Firebase account.
firebase login

4. Set up your FastFile and distribute your app

  • Open android/fastlane/Fastfile
  • To add App Distribution to your Fastlane configuration, run the following command from the root of your Android project:
fastlane add_plugin firebase_app_distribution
  • Add a firebase_app_distribution block in android/fastlane/Fastfile
platform :android do
desc "My awesome app"
lane :distribute do
build_android_app(
task: "assemble",
flavor: "uat",
build_type: "Release")
# build_android_app is a built-in fastlane action.
release = firebase_app_distribution(
app: "1:123456789:android:abcd1234",
testers: "tester1@company.com, tester2@company.com",
release_notes: "Lots of amazing new features to test out!",
android_artifact_type: "APK",
android_artifact_path: "../build/app/outputs/apk/uat/release/app-release.apk",
)
end
end
  • To make the build available to testers, run your lane:
fastlane distribute
  • Add a firebase_app_distribution block in ios/fastlane/Fastfile
platform :ios do
desc "My awesome app"
lane :distribute do
build_ios_app(scheme: "DEV",
workspace: "Runner.xcworkspace")
# build_ios_app is a built-in fastlane action.
release = firebase_app_distribution(
app: "1:123456789:android: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 distribute

By combining Fastlane’s automation with Firebase App Distribution’s ease of sharing pre-release builds, you can efficiently streamline your Flutter app’s development and testing process.

--

--