How we Automate iOS App Distribution with Fastlane

On , by

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#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#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

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

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#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#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#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#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#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.

Share this article on Twitter or LinkedIn
Previous Blog Post: How to make a Circular Image View in Android without Third-Party Library
Subscribe to Sudo vs Root

Our newsletter rolls out every month. No fluff. Pure content.

Comments and Discussions
Skcript https://www.skcript.com/svr/how-we-automate-ios-apps-distribution-with-fastlane/ https://www.skcript.com/svrmedia/heroes/Automate%20iOS%20app%20distribution%20with%20fastlane@1.5x.png