How we Automate iOS App Distribution with Fastlane
Fastlane provides an effective and automated way of pushing a build to TestFlight, App store and more. Find out how right here.
Karthik Kamalakannan / 30 August, 2019
iOS App development is not only about writing Swift or Objective - C code. It involves the understanding of how UIKit works, how certificates are made, how App store distribution is done and more. Fastlane helps us to provide a well processed and automated way for pushing a build to TestFlight, App Store and more.
There are several methods for configuring Fastlane if you have installed HomeBrew it is a single command to configure.
brew cask install fastlane
As Fastlane is a Ruby-based gem. The gem is always another option
sudo gem install fastlane -NV
You can also download it from the official website. Once you are done with configuring Fastlane, navigate to the project root directory and run.
This will create Fastfile in your root directory where you configure this Fastfile depending on your need for automation.
With Fastlane, you can write a ruby script for the step by step process where you want to deploy your app. This can be done by using Fastlane actions, Tools and lanes.
Fastlane tools are the core that helps to build your app. On top of the build tool, there is more than 170+ third-party integration so that you can connect to other services and more. Tools help you perform a variety of tasks like taking screenshots, framing them, and lets you run your tests before building it to AppStore.
Fastlane actions are a core tool that helps you to perform a set of actions like testing, taking screenshots, code signing, documentation and much more.
Fastlane has a set of group of actions that help us to achieve the same results every time.
Every time you send a beta version for TestFlight, you will go through a basic checklist: signing the app, uploading it to a beta service, adding a new version to it, etc. Add to this, the things you have to do once (every year): signing certificates, signing push notification certificates, and more. Let's see how Fastlane helps us to automate and publish our app to TestFlight.
For pushing the App to TestFlight, we need to create a signing certificate and a provisional certificate. Fastlane has an action called the match. This creates a distribution certificate and Ad-hoc provisional certificate. Saves both the certificates in git repository encrypted using OpenSSL.
First to get started run
fastlane match init
Once you set your GitHub repo, just call
fastlane match adhoc
To get an ad-hoc provisioning profile
fastlane match appstore
With match, you can easily sync the certificates between teammates and computers.
Now we are ready with the certificates. Let's see how we can release it to Test Flight. Workflow for pushing your App to Test Flight includes
- Creating a distribution certificate
- Creating a Provisional certificate
- Set your app to use your Provisional certificate
- Archive your App
- Open AppStoreConnect and follow the steps and send the app to beta testers
Now add this following lane in your Fastfile configuration which I mentioned earlier.
platform :ios do lane :beta-testflight do increment_build_number match(type: "adhoc") gym pilot commit_version_bump( xcodeproj: "project.xcodeproj", ) end end
Now running following command in terminal will launch the above script
This is first call increment_build_number action which will increment the build version number. And then match action performs handling signing and provisional certificates and then gym which builds the app with the signing and provisional certificates and then pilot action is used to push the app to Test Flight. Commit_version_bump action is for pushing to Github with commit message like "Version bump to 7"
Fastlane enables app delivery through automation and takes off the burden of app delivery for iOS developer by a one-click solution for creating the certificate, syncing certificate, building application, packaging application and much more.
Last updated: November 21st, 2023 at 6:56:16 PM GMT+0