Streamline Your App Deployment with Fastlane

The Power of Automation

As a developer, you know how tedious it can be to handle Android and iOS app deployments. From screenshots to beta deployments, App Store deployments, and code signing, the process can be overwhelming. That’s where Fastlane comes in – an open-source tool suite that automates releases and deployments, saving you hours of time and effort.

Getting Started with Fastlane and Flutter

To begin, you’ll need:

  • An active Flutter application
  • Familiarity with Flutter and Flutter SDK
  • Familiarity with Firebase and Firebase CLI installed on your device
  • Homebrew installed (if you haven’t, here’s a guide on how to do so on Mac)

Setting Up Fastlane

First, install Fastlane using the command below:


gem install fastlane

To confirm the installation, check the version by running:


fastlane --version

Unique Package Name

Your application’s package name must be distinct. If you created your Flutter application using Android Studio, you’ll already have a default package name assigned. However, this may not be unique on Google Play or the App Store. To change your package name, follow these steps:

  • Open Android Studio and click on the settings icon at the top
  • Uncheck the Compact Directories option
  • Refactor your package name by right-clicking on your application’s package name and selecting Refactor, then Rename

Supply and JSON File

Supply is a tool in Fastlane that enables you to upload app metadata, binaries, and screenshots to Google Play. To initialize Supply, you need to have successfully uploaded an APK to your app in the Google Play Console at least once. To get your JSON secret file, follow these steps:

  • Open your Google Play Console account and note the Developer Account ID
  • Click on Setup, then API access
  • Create a new service account and follow the prompts to generate a JSON key file

Initializing Fastlane

To initialize Fastlane for Android deployment, navigate to your Android folder directory and run:


fastlane init

You’ll be prompted to input your application package name and the path to your JSON secret file. Once complete, you’ll see a Fastlane folder in the Android directory with an Appfile and a fastfile.

Deploying to Firebase App Distribution

To demonstrate Fastlane’s capabilities, let’s deploy our APK to Firebase App Distribution. First, set up your Firebase project by following these steps:

  • Head to the Google Firebase Console and create an account if you don’t already have one
  • Click Create a project and specify your project name
  • Select App Distribution and the Android icon
  • Register your application with the same package name as specified in your application

Next, assign Flutter app distribution to Fastlane by executing the following command in your terminal:


fastlane supply init

Replace the existing code in your Fastlane file with the code below to map Fastlane distribution to deploy to Firebase:

“`ruby
lane :deploy do
# Your Firebase CLI token
firebaseclitoken = “YOURFIREBASECLI_TOKEN”

# Your App ID from the Firebase console
appid = “YOURAPP_ID”

# Deploy to Firebase App Distribution
firebaseappdistribution(
appid: appid,
firebaseclitoken: firebaseclitoken
)
end
“`

Finally, deploy your application by specifying the lane you wish to deploy:


fastlane deploy

This command will upload the APK specified in that particular lane. Once completed, you can head to your Firebase console and view your application deployed using Fastlane.

Happy Coding!

Fastlane is a powerful tool that simplifies the app deployment process, saving you hours of time and effort. By following this guide, you’ve successfully set up Fastlane with your Flutter application and deployed it to Firebase App Distribution. Check out the official documentation to learn more about Fastlane and its capabilities.

Leave a Reply

Your email address will not be published. Required fields are marked *