Publishing Flutter Builds with Fastlane and Firebase App Distribution 🚀
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
(orbrew install fastlane
on macOS)
Setting Up Fastlane
- Initialize the Fastlane projects for each platform.
Android setup -
- In your
[project]/android
directory, runfastlane 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, runfastlane init
. - Select
Manual setup — manually setup your projects to automate tasks
inWhat 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 theandroid/fastlane
directory. - Find the
package_name
property within thefastlane
block. Ensure this value exactly matches the package name you found in theAndroidManifest.xml
file. If there's a mismatch, correct it in theAppfile
.
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 theios/fastlane
directory. - Find the
app_identifier
property within thefastlane
block. Verify that it precisely matches the bundle identifier you retrieved fromInfo.plist
. If there's a discrepancy, update theAppfile
.
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 inandroid/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 inios/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.