One of the most tedious tasks in iOS development is the submission of app in App Store. If you have ever tried to push an app into Apple Store, you know how lengthy the steps involved are - archiving the app, exporting it to App Store, adding the new build, adding screenshots for a particular device and finally make it available to the entire world. Fortunately a new tooling has evolved for the whole process, making it far easier - fastlane.
fastlane is a collection of tools and the easiest way to automate deployments and release your iOS and Android apps. This article focuses on the iOS aspect. It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing the application.
fastlane is not just a single tool. It is a collection of twelve tools(at the time of writing) for iOS which depend and interact with each other. fastlane is wrapped around these tools, allowing developers to define workflows, which also known as lanes. Each workflow requires different tools to run. For example, Snapshot is a tool which allows you to automatically take the screenshots of your app.
A typical workflow in fastlane looks like this:
lane :appstore do
snapshot # Generate screenshots of app for the App Store
gym # Build your app
deliver # Upload the screenshots of app and the binary to iTunes
Here you define a lane to generate screenshots, build app and upload binary to iTunes.
The list of Fastlane tools also called Fastlane commands is given below:
Installation: Before you start using fastlane, you need to make sure that the Xcode Command Line Tools are installed. Execute xcode-select --install from command line to install it. Fastlane is a Ruby gem. Depending on the system, you have to either run gem install fastlane or sudo gem install fastlane.
Setting up Fastlane in iOS project: After creating your Xcode project, move it to the project folder and run fastlane init from the command line. Then a script will prompt you for your apple ID and probably password if it is not present in the keychain. The script also detects the different attributes of your app such as name and identifier, and checks the Developer Portal and iTunes Connect if the app is already present. If it isn't, then it offers to create it for you .
After the setup process, you can see a newly created fastlane directory. The file is named as fastfile which contains all your existing metadata fetched from iTunes Connect. The most interesting thing about Fastfile is that it contains all the information that is needed to distribute your app. Here is the default appstore lane.
lane :appstore do
This lane or workflow does the following things:
fastlane has already created all the essential files. You can now customise it using the different tools available to generate screenshots or to automatically distribute new builds etc. You can also connect Slack and fastlane in order to notify teams through messages in a channel once the app is processing, or has been publishing, or when unit test are failing etc.
The main advantage of fastlane is that it saves much time when you release an update or new app. Others are listed below
By using Fastlane, you can reduce the time and effort needed to deploy an app to App Store through automating the different steps. Fastlane also offers a ton of integrations which helps to customize your lanes to get real time feedback on Slack, perform unit tests and deploy TestFlight builds. For more information, check out the documentation on GitHub
To learn more about this fantastic tool, take a look at the official fastlane website.