Fastlane

Building and deploying mobile applications can be a tedious process. For iOS specifically, bumping build numbers, archiving builds, and uploading to the app store is a multi-step process that is definitely a pain point.

Automate as many manual actions as you can

Here at Revelry we have looked to automating our deploy process to save time by cutting down on some of those manual actions. Enter fastlane. Fastlane is a collection of tools that can be used to develop what they call “lanes” that define a build and deployment pipeline.

Let’s talk about installing and configuring fastlane and getting our first build up into TestFlight for internal testing. For the sake of this write up, I will assume that you already have an iOS application and that you have registered a bundleID for your application.

1. Install Fastlane

Installing fastlane is as simple as installing any Ruby gem. You install it in the root directory of your project with “gem install fastlane”. You can begin to configure your setup by running “fastlane init”. This will lead to a few command line prompts that asks questions about your application.

This will create a fastlane directory that contains most importantly, an Appfile and a Fastfile. The Appfile is a place to store your app’s identifier and your iTunes Connect username so that you will not be prompted for it again next time you run a fastlane command. The Fastfile is where you will soon define your build lanes!

2. Add Match

Before we create our first lane, one other thing we should do is set up match. Match is another tool within the fastlane umbrella that manages provisioning profiles and signing certificates in a private repository.

Match can also be used on its own, and is arguably the most useful service of the bunch. It provides a way to sync and manage your profiles and certificates in a private GitHub repository that you create so that you and your team members can all use one set of credentials to build and sign your applications.

3. Organize your repo

Before beginning this process, you will need to create a private GitHub repository to store your provisioning profiles and certificates in. Just like initializing fastlane, you will be able to run “fastlane match init” which generates your MatchFile. Again, you will be prompted with questions about your application, your developer account, and the url of your GitHub repo. After setup is complete, you can run “match development”, “match appstore”, or “match adhoc”.

The commands will check to see if you have that type of profile already created and synced in your repo. If you don’t, it will create the profile and certificate, upload it to your repo, and download it locally to your machine. If the pair already exists, it will simply download it from the repo or use the local copy.

The beauty here is that the next person can simply run “match development” in order to acquire the necessary credentials to develop your app locally, given that they have access to the repository and have the applied passcode.

Your deploy process is now that much faster

Now that match is setup, back to the lanes! Here is what a basic lane that pushes new builds to TestFlight looks like:

lane :beta do
  match(type: "appstore")
  increment_build_number
  gym
  pilot
end

The first step of our lane is going to leverage match in order to create a release version of our app that can be uploaded to TestFlight, which is why it uses the “appstore” type. The next step, an optional one that I find useful, just bumps the build number of your app by one so that TestFlight will accept it since you cannot upload redundant builds.

Next is Gym which is what actually creates the .ipa of your app that will be uploaded. Finally Pilot, which uploads the app to TestFlight. Normally, we would need to open our project, bump the build number, archive the build, and finally upload the app to TestFlight.

Now to deploy our app to TestFlight, we simply run ‘fastlane beta’ from the command line and wait. That’s it! Happy deploying.

We're building an AI-powered Product Operations Cloud, leveraging AI in almost every aspect of the software delivery lifecycle. Want to test drive it with us? Join the ProdOps party at ProdOps.ai.