fbpx

A Guide to Continuous Delivery on iOS With Fastlane and Firebase

Configure once and save 30 minutes each time you build for release.

In this article, we’ll learn about continuous delivery and its implementation in the iOS eco-system.

Continuous Delivery (CD) is the process of automating the build using some external tools/software, which reduces manual developer effort to create the build so you can share the build reliably in no time.

Normally, Continuous Integration (CI)is also implemented with CD, but it’s not compulsory to implement both at the same time.

In CIthedeveloper’s code is merged continuously, to maintain the latest deployable code all the time. CD is as effective for a sole-developer as for large teams, as you have to share/deploy the build.

So, in this article, we will focus on implementing continuous delivery for the iOS platform using Fastlane and Firebase for sharing the beta build with testers/clients.

Here are some typical tasks that we repeat every time we share a build.

  1. Build the app in different environments (staging/production).
  2. Signing the builds according to specified environments.
  3. Exporting the app and manually configure the settings for the build.
  4. Uploading it to distribution platforms (like DiawiTestFlightCrashlytics).
  5. Share installable build links with release notes (in some cases).

With continuous delivery, you can automate all the above steps.

Outline

These are some steps that we are going to implement in the article.

  • Set up Fastlane — We will install Fastlane on the system, then configure Fastlane with the iOS project. Fastlane is responsible for auto-deployment tasks.
  • Configure Fastlane — We will implement our configuration for desired targets (staging or production, etc., one may have more than two records). Fastfile will tell Fastlane about compile information.
  • Exporting the build — We will export the build through the terminal with configurations specified in Fastfile.
  • Setting up app Firebase distribution — We will configure the app on the Firebase console, we can add testers or groups for the app that we will share with tester or clients.
  • Automating the build push to Firebase — We will configure the Fastlane file, so building the destruction process becomes automated.
  • Enjoying the coffee:Yeah, we have automated the process and save some of our time.

You can also check out the tools that we are using in the CD process.

Let’s begin the game.

Set Up Fastlane

First, you have to install Fastlane tools on your system.

Install the latest Xcode command-line tools:

xcode-select --install

Install Fastlane using:

# Using RubyGems
sudo gem install fastlane -NV# Alternatively using Homebrew
brew install fastlane

After installation, you can verify the installation of Fastlane tools, with this command.

fastlane -v
Image for post

After the installation of the tools, you have to change the terminal directory to the project’s directory and then initialize Fastlane tools with the below command:

fastlane init

On this command, you will have to choose the purpose for which Fastlane tools will be used. After that, log in to the Apple account on the terminal.

Image for post

After the initialization of Fastlane, you will see a Fastlane-named directory in your project’s directory, containing the Fastfile in which we will configure meta information.

Configure Fastlane

We will have to configure the steps that we will automate with Fastlane tools.

Image for post
increment_build_number(xcodeproj: "TestProject.xcodeproj")
build_app(workspace: "TestProject.xcworkspace", scheme: "TestProject-staging", export_method: "ad-hoc", silent: "true", output_directory: "./build_ipa")

We are going to implement the process of automating beta testing, configure the parameters of build_app according to that. If you have multiple targets, you can set multiple lanes like production_adhoc, etc.

  • scheme: Target name of your project.
  • export method: Export method for build creations like app-storead-hocdevelopment, etc.
  • output_directory: Where the exported .ipa will be placed.
  • silent: Hide all information that is not necessary while building.
  • Explore other Fastlane params.

Exporting build

Once you have configured the lane for deployment, you just have to run the below command for build exporting:

fastlane staging_adhoc

Replace staging_ahoc with your lane name.

It will show the message on the terminal after the .ipa file is exported.

Now you can share the .ipa file through different sources like Diawi, TestFlight, Firebase App Distribution, manually.

Our next step is to automate the build sharing process. Fastlane supports many distribution platforms for build sharing, I’m going to use Firebase in this tutorial.

Firebase

Setting up app Firebase distribution

It’s supposed you have configured the Firebase project from the console with your iOS project.

Add App Distribution to your Fastlane configuration by running the following command from the root of your iOS project:

fastlane add_plugin firebase_app_distribution

After installing the Firebase plugin, you have to configure the Fastlane file.

Image for post
increment_build_number(xcodeproj: “TestProject.xcodeproj”)
build_app(workspace: “TestProject.xcworkspace”, scheme: “TestProject-staging”, export_method: “ad-hoc”, silent: “true”, output_directory: “./build_ipa”)
firebase_app_distribution(
app: “Your firebase App Id”,
groups: “internal-tester, clients”,
release_notes: “Lots of amazing new features to test out!”,
firebase_cli_path: “/usr/local/bin/firebase” )
  • app: App ID of the Firebase app, you can get it from the Firebase console.
  • group: You can specify the group with which you want to share the build, like I have created a group of testers for internal testing, another one for client sharing.
  • release_notes: Any changes or updates that are implemented in the build, you can share it with the testers.
  • firebase_cli_path:firebase_cli_path will be the same if we haven’t explicitly changed the Firebase tools installation path.

Automating the build push to Firebase:

Once we have updated the Fastfile, we have to log in Firebase into the console. After login, run the below command.

bundle exce fastlane staging_adhoc

Replace staging_adhoc with your lane name.

Coffee Time

Congratulations, we have automated the deployment and distribution process. You will see a Fastlane summary at the end after the successful distribution of the build on Firebase.

Image for post

A Guide to Continuous Delivery on iOS With Fastlane and Firebase

Leave a Reply

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

Scroll to top