How To Automate Mobile Application Releases With Fastlane

We live in a highly dynamic tech landscape where new versions of applications are released daily to introduce new features, fix bugs, enhance user experience, and ultimately, increase product quality and stand out in app stores.

With this comes a challenge: how can the release of new versions be automated to speed up the distribution process of these applications? 

There are several points related to the app distribution chain that make the process quite complex and filled with challenges.

The wide variety of platforms and smartphone versions require a different approach. Each platform has complex configurations necessary for its execution and its own method of application signing, which is crucial for information security since sensitive data is used for this purpose. 

The variety of programming languages ​​is also an important point to consider. Developers can build applications with a wide variety of languages ​​like Java, Kotlin, Swift, Objective-C, React Native, Flutter, and many more.

Plus, to follow best practices, it’s necessary to have a production environment and environments for testing and validation, such as the development environment and user acceptance testing environment. Configuring and managing the app stores is also necessary so that application versions are released correctly.

And, of course, you have to do all of this quickly to stay competitive in the market. That’s a lot to juggle! 

Thankfully, there are clever solutions that can help tackle these challenges. In this article, we’ll explore how Fastlane can help developers automate and streamline the mobile app deployment process, ensuring continuous and reliable delivery.


In this post


An overview of Fastlane

Fastlane is a powerful and flexible automation tool designed to simplify the process of developing, testing, and deploying mobile applications. Quickly becoming a popular choice among iOS and Android developers, Fastlane reduces the repetitive and error-prone workload associated with the app development lifecycle.

Key features for mobile application releases

Fastlane’s key features include:

  • Automation of repetitive tasks: Fastlane automates tedious and repetitive tasks such as code compilation, screenshot generation, beta testing deployment, and submission to the App Store or Google Play, among others.
  • Screenshots and metadata generation: It facilitates creating and maintaining high-quality screenshots and metadata for the App Store and Google Play, enabling professional presentation of apps in the stores.
  • Certificate and provision management: Fastlane simplifies the management of signing certificates and provisioning profiles for iOS apps, avoiding common issues related to the expiration or loss of these certificates.
  • Multiplatform support: It’s compatible with native and multiplatform projects, including iOS, Android, and MacOS.
  • Open source: As an open-source tool, Fastlane offers transparency, flexibility, and the possibility of community contribution for its continuous improvement.
  • Integration with CI/CD tools: It seamlessly integrates with leading Continuous Integration and Continuous Delivery tools in the market, such as Jenkins, Travis CI, CircleCI, GitHub Actions, among others, enabling the creation of automated pipelines to ensure continuous and reliable delivery of new app versions.
  • Numerous plugins: Fastlane boasts a vast library of plugins offering various additional functionalities, allowing for customization and extension of its features as needed.

Why use Fastlane?

If that impressive list of features isn’t enough to convince you to try out Fastlane, here’s a few more reasons:

  • Time and effort savings: By automating manual tasks, Fastlane saves developers time and effort, letting them focus on higher-value activities such as feature enhancement and user experience.
  • Standardization and consistency: Fastlane helps ensure that the development and deployment processes follow consistent standards, reducing the likelihood of human errors and improving the overall product quality.
  • Agility and flexibility: It allows for adjusting and customizing workflows according to the project’s specific needs, ensuring an agile and adaptable approach to app development.

Prerequisites to using Fastlane

To use Fastlane, you need to have a few prerequisites: 

  • Basic knowledge of app development: While Fastlane automates many aspects of app development and deployment, it’s essential to have a basic understanding of app development to comprehend the processes being automated. This includes understanding the app lifecycle, compilation and deployment steps, and the specific requirements of iOS and Android platforms.
  • Configured and functional mobile project: A configured and functional mobile project is necessary before integrating Fastlane. This involves correctly setting up the development environment, defining dependencies, and ensuring the code compiles and runs as expected.
  • Google Play developer account: If you’re deploying an Android App, you need a developer account on Google Play Console.
  • App configuration on Google Play: Before automating deployment processes on Android, it’s essential to configure the app on Google Play Console, including creating the app, defining release settings, and obtaining service credentials.
  • App Store developer account: If you’re deploying an iOS App, you need a developer account on App Store Connect.
  • App configuration on the App Store: Before automating deployment processes on iOS, it’s necessary to configure the app on App Store Connect, including creating the app, defining provisioning profiles, and obtaining API keys.

Some Fastlane plugins and actions allow the app to be configured on the Google and Apple stores.

However, in this article, we’ll assume that the apps are already configured. Since this task is usually performed once, it’s often done directly in the store.

First steps to automating mobile deployment with Fastlane

Fastlane is a highly flexible tool that allows you to create custom scripts to meet the specific needs of each case.

Before we proceed with the instructions, it’s important to highlight some key concepts of automation scripts:

  • Lanes: These are sets of actions defined in the Fastfile that represent specific workflows. For example, you can have a lane called “release” that compiles your application, generates screenshots, and uploads it to the app store. Lanes allow organizing and automating common tasks in app development and distribution.
  • Actions: These are the individual units of work in Fastlane. Each action performs a specific task, such as compiling an app, uploading screenshots, sending notifications, etc. Actions are used within lanes to define Fastlane’s behavior at each stage of the workflow.
  • Plugins: These are packages of additional functionalities that can be integrated into Fastlane to extend its capabilities and provide new features. Plugins can be used to automate specific tasks, add integrations with third-party tools, or even create new custom actions. This allows Fastlane to be more flexible and adaptable to the project’s unique needs.

In the following sections, we will demonstrate the main commands that can be executed to start the process of creating scripts and automating processes.

Using Fastlane for Android app releases in 7 steps

Here’s how you can use Fastlane for Android applications.

  1. Initial setup

Before you begin, make sure you have Fastlane installed on your system. If you haven’t installed it yet, you can follow the installation instructions in the official Fastlane documentation: Fastlane Setup Documentation.

  1. Initialize Fastlane in your project

Open a terminal in the root directory of your Android project and execute the following command to start the Fastlane setup wizard:

$ fastlane init

This command will initialize Fastlane in your project and guide you through the setup process.

  1. Provide the package name

Provide your application’s package name so Fastlane can create the automation process tailored to the corresponding app.

  1. Download existing metadata

This step is optional. If you intend to use Fastlane for tasks beyond distribution, such as automatic screenshot uploads, it’s important to follow this step. We won’t be doing this in the example below, so we’ll skip this step.

  1. Review the generated files

Fastlane will generate two essential files: Appfile and Fastfile.

Appfile

The Appfile will store important information about the app, like the package name and the path to the Google Play API authentication file.

Fastfile

The Fastfile generated for the example app contains three suggested lanes: 

  • Test for running the application tests 
  • Beta for distributing beta versions to Crashlytics 
  • Deploy for distributing versions to the Google Play Store 

Several actions are used within these lanes:

  • gradle: Gradle is also an automation tool widely used to automate testing and building processes. We see that the action is suggested in all three lanes, both for running tests and building the application.
  • crashlytics: This action is used to upload the app to Crashlytics, which is a Firebase tool for monitoring errors and crashes in mobile applications.
  • upload_to_play_store: This action uploads the app to the Play Store.
  1. Customize the generated files

As observed in the previous step, Fastlane has already set up a basic standard script with some suggested tasks that can be executed. Now, you can tailor the file according to your needs. The Fastlane documentation provides a comprehensive list of all available actions and plugins for this purpose, along with examples of beta distribution and production deployment.

  1. Execute the automation

Once everything is set up, you can execute the automation using the fastlane command followed by the name of the created lane. 

For example, if you want to execute the “beta” lane:

$ fastlane beta

Using Fastlane for iOS app releases in 8 steps

Here’s the process for using Fastlane to automate iOS app releases.

  1. Initial setup

Make sure to have Fastlane installed on your system. If not installed yet, you can follow the installation instructions in the official Fastlane documentation: Fastlane Setup for iOS.

  1. Initialize Fastlane in your project

Open a terminal in the root directory of your iOS project and execute the following command to start the Fastlane setup wizard:

$ fastlane init
  1. Choose the task to automate

The Fastlane wizard prompts you to choose the task to automate. In this case, we chose option two, which automates the distribution of beta versions to TestFlight, Apple’s beta testing platform.

  1. Choose the scheme to use

Depending on your needs and how the project is structured, Fastlane may prompt you to choose which scheme to use in building the scripts. 

In this example, we have three environments and will automate the distribution for the development environment. Of course, you can edit the scripts after running the wizard to expand to other environments.

  1. Connect to App Store Connect and Apple Developer Portal

Fastlane will request your Apple ID to connect to App Store Connect and the Apple Developer Portal. It’s important to use an Apple ID with access to the account where the apps you want to automate are located. 

If the selected Apple ID has access to more than one account/organization, Fastlane will prompt you to select which account to use.

  1. Review the generated files

Just like in the Android setup, Fastlane will generate the same two files (Appfile and Fastfile) for iOS.

Appfile

The Appfile will store important information about the app, such as the identifier, the Apple ID authorized to integrate with the store, the App Store Connect team ID, and the Developer Portal team ID.

Fastfile

The generated Fastfile for the example application is quite simple, with only one lane called “beta” where three actions are executed:

  • increment_build_number: This action will increment the build number of the iOS project.
  • Build_app: This is the action that will build the application, in this case, using the dev scheme.
  • upload_to_testflight: This action will upload the app to TestFlight.
  1. Customize the generated files

As mentioned in the previous step, the script file generated by Fastlane is quite simple and serves merely as a starting point. It should be tailored to meet the unique needs of each project, and you’ll likely want to incorporate various actions, such as Match, a plugin designed to streamline the creation and management of certificates and provisioning profiles. 

The Fastlane documentation provides a comprehensive list of all available actions and plugins for this purpose, along with examples of beta distribution and production deployment.

  1. Execute the automation

Here, the process mirrors that described for Android — simply execute the automation using the fastlane command followed by the name of the created lane. 

For example, if the lane is named “beta”:

$ fastlane beta

It’s important to note that plugins and actions are available on both platforms and can be used to craft the script with functionalities ranging from automating application versioning to sending notifications via Slack.

Actions require parameters for proper execution depending on the project and goals to be achieved, so it’s crucial to consult the documentation.

Once the scripts are created and customized, you can integrate them into the development cycle by incorporating them into CI/CD pipelines.

Installation of Ruby and Fastlane on the machines responsible for running the pipelines is necessary, and it’s worth remembering that machines with macOS must be available for executing iOS pipelines.

Fastlane: a great way to speed up application releases across platforms

Companies and developers will always have one thing in common — they want to save time. Automating mobile application releases with Fastlane is an excellent way to do just that.

Fastlane not only speeds up the development and release process but also does so securely and consistently, thanks to a free, open-source tool.

This approach to mobile application releases helps keep things standardized and repeatable, saving time and money in the long term. 

To learn more about improving your app development processes, have a look through the Cheesecake Labs blog, where our team members share insights and tips to help you create the best digital products and experiences. 

And for companies intrigued by how we use Fastlane and other tools in our app development services, send us a message. We’d love to chat!

About the author.

Álan Monteiro
Álan Monteiro

The guy from security, automation, camping, motorcycle, travel, and collaboration! Let’s talk?