Over the past few months, we’ve really ramped up the number of meetups and conferences we talk at here at RIIS. One of the best things about giving a talk is not necessarily what you say but also what you hear. In the last few months I’ve heard Fastlane mentioned several times when talking about Agile Dev and I thought it would be a great candidate for a blog.
In a nutshell Fastlane makes part of the build process much simpler. As we’ll see it’s real value is at the deployment stage or at the end of the build process.
Why would you want to use Fastlane? Well build tools are notoriously arcane and difficult to use. To make things worse, in many organizations it’s a rare event to upload a new build to iTunes or Google Play. Meaning there is a significant chance that the person who deployed your app the last time is no longer with the organization. Fastlane’s beauty is that it codifies this complexity into simple commands so you can just run fastlane beta or fastlane deliver to test or deploy your app.
What is Fastlane
Fastlane can be confusing because it’s more than just one thing. It is a bunch of different tools that are used separately or together in lanes to give you whatever build you want. Some of the underlying tools are for iOS and some are for Android and some of these available tools work for both platforms. Figure 1 shows three different example lanes.
Figure 1: Fastlane tools
The first lane uses scan to run your tests followed by snapshot to generate screenshots for iTunes on all devices so you don’t have to spend any time generating them. Scan and snapshot both use underlying Xcode commands but they hide its complexity.
Lane 2 scans again but then adds pilot to upload and distributes your builds on Testflight. Slack sends a message on a slack channel to tell your colleagues that your app has been built and to go and install it.
Lane 3 first scans and takes snapshots again. This is followed by sigh which manages your provisioning profiles, gym builds your app and deliver deploys your app to iTunes in a single command.
And that’s not every tool there’s also frameit, pem, supply, screengrab as well as a number of other third party tools.
To create your own fastlane take the following steps
1. Download and install fastlane using the brew cask install fastlane command
2. Run fastlane init which will gather your iTunes or Google Play information and create a fastlane directory and config file called Fastfile
3. Edit the config file and create your own lane, in the example below we’re using gym to build the ETAMock app.
4. Run fastlane [lane_name] or in our case fastlane beta
lane :beta do gym(scheme: "ETAMock", workspace: "ETAMock.xcworkspace", include_bitcode: true) end Listing 1: Fastfile config file
Fastlane also has an interactive tool for building more complicated Fastfile config files.
Fastlane is an open source Ruby project that was created by Felix Krauze. It’s been around since 2014 in one form or another and is part of Fabric suite of tools. Up until Jan 2017 it was under the Twitter umbrella but is now owned by Google. However Fastlane will work for both iOS and Android builds.
Fastlane brings a great deal of speed and simplicity to a task that can be confusing and error prone. It codifies the complexity of the build process so that cross training teams to do the builds becomes trivial. You can use it from the command line or preferably from a Continuous Integration server.