Send inquiry

How to automate the build and release of mobile apps? With Fastlane!

In our next technical article, we take a look at the topic of building and releasing apps for Android and iOS platforms. We reveal our approach to these activities and bring a brief tutorial for other developers. 

App publishing = a relatively difficult process

When developing an app, it is appropriate to continuously test its finished parts. To do that the developer has to archive the app using the XCode developing environment and then upload the file for testers to Testflight (or to another testing portal). When the app is finished, clear of all flaws and ready for production release in the AppStore, it is necessary to repeat this process and upload the screenshots of the app in all supported languages. Moreover, it is crucial to administrate the certificates which can be a tedious task. Wouldn't it be great if we could avoid this thanks to a tool that would automate the whole process? 

Fastlane tool - a very clever assistant  

Fastlane is probably the easiest way to automate the build and release of apps for Android/iOS platforms. It will take care of certain steps which would otherwise needlessly occupy our time. We are speaking of automatic app version updates, app archiving, changelog, etc. 

Fastlane functions:

  • Automatic generation of screenshots in all supported languages and for all supported devices
  • Beta Deployment - Creating a beta version of continuous development for the testers
  • AppStore Deployment - Release of the new production version for the AppStore
  • Code Signing - Administration of certificates required for the development and the release

After this process is over, Fastlane can send a message to Slack informing all members of the channel about the app's release. It is also possible to integrate Fastlane to an already existing CI (Bitrise, Jenkins,...), which makes the whole process even more comfortable. 

Enough of theory, let's jump to its installation and implementation into a project! 

There are more ways to install Fastlane. Here in Dactyl we have used Ruby, however, you can also install it by using HomeBrew. 

HomeBrew installation

brew install fastlane


Next, we recommend setting up a Fastlane match for certificate administration. We will not describe this process here, only paste a link to the setting as you can find a well-written manual on Fastlane's official website. 

After having successfully installed Fastlane, we will now move to the project's folder and enter this formula in the terminal: 

fastlane init

This will generate several new files in the project - Appfile, Gemfile, and Fastfile.
Let´s now add one more file named Pluginfile in the project. There, we will install the plugin for an automatic app version upgrade. This can be done by inserting one line in the newly created file. 

gem 'fastlane-plugin-versioning'

Gemfile - serves for implementation of gems for Fastlane 
AppFile - contains an Apple ID
Fastfile - administrates individual lanes.
In this tutorial, we will show you how to set up a lane so that Fastlane releases an app version for the testers. Nevertheless, the steps of each developer may vary because everyone has their own requirements so it is not necessary to strictly follow this manual. 

We will set the app ID in the AppFile so that it matches the app_identifier in both Xcode and App Store Connect

for_platform :ios do 
  for_lane :beta do 
     app_identifier 'bundle_id_application' 


Then, we can set up the last Fastfile. Firstly, we have to establish the name of the initial lane and define the steps which will take place throughout the process. In the beginning, it is recommended to create a few variables in the file which we can use with a higher number of lanes (for example one variable for beta, another one for the production release).

buildFinalTarget = '' 
currentBranch = '' 
xcodeproj = 'yourApplication.xcodeproj' 
appleID = ''

After that, we can create the first lane

lane :beta do 
    buildFinalTarget = 'nameofYourTarget' 
    currentBranch = 'nameofBranch' 
    appleID = 'yourAppleId' 


  • buildFinalTarget - the name of the target from which you will make the build
  • currentBranch - the name of the branch which will be used for the build
  • appleID - your Apple ID - can be retrieved from AppStore Connect.
  • test_flight_build() a commit_version() will be defined below.

 Subsequently, we will add test_flight_build(), which will build our app for TestFlight

lane :test_flight_build do

    desc "Push a new #{buildFinalTarget} build to TestFlight" 

      xcodeproj: xcodeproj 

      type: 'appstore', 
      readonly: true

      clean: false, 
      workspace: "lifeapp-ios.xcworkspace", 
      configuration: "YourConfiguration", 
      scheme: buildFinalTarget,
      export_method: "app-store", 
      output_directory: "./build", 
      include_bitcode: true


Configuration can be for example “Release”, “Beta” etc. 

The last step is the implementation of  commit_version, which will create a commit with a new version. It is also possible to define your own commit or make other steps that you would like.  

 lane :commit_version do

   build_number = get_build_number(xcodeproj: xcodeproj)
   version = get_version_number(
     xcodeproj: xcodeproj, 
     target: buildFinalTarget
     message: "Release-#{version}-#{build_number}", 
     grouping: "fastlane", 
     prefix: "#{version}-" 
      remote_branch: currentBranch, 
      force: true, 
      tags: true 


Now, everything should be set and ready for our first build! Before you run the Fastlane itself, make sure that all the changes are committed and there are no unfinished ones. To launch the process you only have to go to the project folder and write this command:

fastlane beta


If everything is in order, you should see something like this! 

We hope you will find this tutorial useful! If you have encountered a problem or you have any questions, do not hesitate to contact us!
The author of this text is Kevin Singh, our mobile team leader.