Automatic deployment with fastlane

Automatic deployment is the ability to create a beta or an App Store version of an app with just one click or command. It is of great benefit to be able to ship a version without all the hassle of provisioning profiles and code signing (often referred to as code signing hell). Felix Krause, a developer, started a project named fastlane.tools to make deployment on iOS as easy as running a command in Terminal.app. We will use fastlane in this section to set up automatic deployment for our ToDo app.

Go to fastlane.tools (put fastlane.tools in your browser) and follow the installation guide. We won't repeat the steps here because fastlane is still in active development, and the probability that the installation process changes before this book is published is very high.

Open Terminal.app and navigate to the folder with the ToDo project. Put in the following command, press enter, and follow the instructions on the screen:

When you are asked if you want to setup deliver or snapshot, put in n for No. But we want to use sigh to automatically create and download provisioning profiles for the app. The next step is to add the app to your developer portal. Put the following command into Terminal.app and press enter:

You will be asked for the credentials of your Apple ID. The password you provide here will be stored in the keychain. When asked about the app name, put in a good name for the app. This name will be used to create the app in iTunes Connect. If there is already an app with that name in the App Store, fastlane will tell you so. In this case, run produce again and choose another name.

Before we can create a beta build and load it to TestFlight, the app needs an icon file that is 120 x 120 in size. Create your own icon or use this:

Setting up

Add the icon by navigating to Assets.xcassets | AppIcon | iPhone App iOS 7-9 60 pt | 2x.

To create a beta build and load it to TestFlight, use this simple command:

Fastlane fetches the required provisioning profile, builds the app, and loads it into TestFlight. The whole process takes a while. But everything runs automatically and you can do something else until the upload is finished.

If this is your first upload, fastlane will print something like this:

You can now open iTunes Connect, and submit the build for beta review. This is how you can perform automatic deployments using fastlane.

Among others, fastlane is also able to upload the App Store description and screenshots for your app, and it can submit these for review. Have a look at the https://github.com/fastlane/fastlane GitHub page to get some knowledge about the many different tools in fastlane and how they can help you with your day-to-day development tasks.