Fastlane + iOS + Ionic 2/3 = 🚀[Tutorial]

Simranjit Kamboj
3 min readJul 2, 2018

--

Fastlane.tools is a mobile developers best friend when it comes up automation! You don’t have to worry about updating screenshots, build number, or submitting your app for review.

Fastlane even takes care of code signing and deploying for beta testing. Fastlane integrated easily with continuous integration services like Travis CI or Jenkins (not covered in this tutorial).

Let’s get started with the setup!

  • First, we have to install Fastlane and bundler

[sudo] gem install fastlane -NV or brew cask install fastlane

and

gem install bundler

  • Now navigate to your Ionic project. create a folder called automatic-build and run: fastlane init for Objective C or fastlane init swift for swift. A new folder should be generated called fastlane within which are files that we will be editing.
  • Within automatic-build/fastlane , create a file called .env. Make sure you change the values to match your app. You can setup incoming webhooks in Slack and paste the link here. We will setup the automatic Slack notifications later. We will add the following to the file:
  • Let’s start configuring the files that were created within automatic-build/fastlane. Open up Appfileand configure it to hold the following:
  • Let’s create another file in the automatic-build/fastlane folder called Matchfile. We will have to create a private repository before filling out this file. You can create a private repository on Github or Bitbucket. This file will hold information about our repository for storing the signing certificates. Once you have the repository created, we can add it to the file.
  • Create a new file in the automatic-build/fastlane folder called Gymfile. It will hold the information about our Xcode project.

The most important part begins now. Configuring the Fastfile

This holds the details about building the app, increasing the build number, submitting it to the app store and all the other cool stuff! If you open the Fastfile that was automatically created earlier, it should already have the following filled out:

A lane in Fastlane is like a function. We’ll start by making one that will create our app. Add the following to your Fastfile, after the end of the custom_lane.

In order to create the app, we need to run this lane. We can do it by running the following:fastlane createNewApp

Fastlane might ask you for some information, like your password for your iTunes developer account. Fill out all this information and then you’re ready to configure the actual build of the app!

Now we can start the automated deployment process

We will create more lanes in our Fastfile. The next lane we are going to create will help us out with building the project, certificates, increment build number, create the IPA, and push to iTunes Connect.

Add this to your Fastfile:

Running the lane to upload the project to iTunes Connect

In your projects root folder, create a file called iosBetaBuild.sh and fill it with the following:

This will build the iOS project and run the beta lane to run our automated setup! Let this run for some time because it will take some time if your app is on the bigger side. If you set up your slack webhook, you will get notified automatically when everything is completed, yay!

The app should now be available in iTunes Connect. If you don’t see it right away, give it a few minutes because Apple needs to process it.

Submitting the app to the App Store

You need to make a slight change to the Fastfile. The lane for building the app and uploading to the app store will look the like following:

Running the lane to upload a new build to the App Store

Create a file in the root of your project called iosReleaseBuild.shand add the following:

That’s all it takes to get Fastlane setup and automating the tedious stuff! This tutorial was inspired by Simon’s tutorial on Ionic and Fastlane. There were some spots where I got a bit confused and made mistakes, so I decided to post my version of it.

I am considering doing a tutorial on how to automate iOS screenshots as well as automating Android deployment but that is still TBD. I will add an update here if I decide on doing it.

I automated the deployment of my own app Clipit through Fastlane as well!

Here’s to saving time with automation.

Cheers,

Simranjit Kamboj

--

--