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

Karthik Kamalakannan

How we Automate iOS App Distribution with Fastlane

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.

Configure Fastlane

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.

fastlane init

This will create Fastfile in your root directory where you configure this Fastfile depending on your need for automation.

Automate Deployment

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

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

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.

Lanes

Fastlane has a set of group of actions that help us to achieve the same results every time.

How to use Fastlane with iOS

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.

Automating Test Flight Beta release

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.

Match

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

  1. Creating a distribution certificate
  2. Creating a Provisional certificate
  3. Set your app to use your Provisional certificate
  4. Archive your App
  5. 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

fastlane beta

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"

Conclusion

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: January 23rd, 2024 at 1:50:36 PM GMT+0

Subscribe

Get notified about new updates on Product Management, Building SaaS, and more.

Skcript 10th Anniversary

Consultants for ambitious businesses.

Copyright © 2024 Skcript Technologies Pvt. Ltd.