iOS Deployments using Fastlane 🏎️
- 2 minutes
- June 27, 2020
In this post, we’ll talk about deploying mobile apps using Fastlane.
Step - 1: Install Fastlane
The first step is to install Fastlane tools on your iOS Project.
To do that, step into the root of your project in a terminal and initialize the
bundler. Yes, this is the same bundler that the good folks in the rails community use.
$ cd /path/to/your/red-goose red-goose$ bundle init
The command above will write a new
And while you’re at it, you might want to add the following massive gist on your
Now open your project on visual studio code (not xcode!) and replace the contents
Gemfile with the following:
// Gemfile: source "https://rubygems.org" gem "fastlane" gem "dotenv"
And then run
$ bundle install to install both Fastlane and Dotenv to your project. Once the installation has completed, check the Fastlane version with:
$ fastlane --version
I was on version
fastlane 2.159.0 at the time of writing this guide.
Done. The first step is complete.
Step - 2: Set up Fastlane
The next step for us is to initialize and configure Fastlane for our iOS builds.
To do that:
red-goose$ fastlane init [✔] 🚀 [✔] Looking for iOS and Android projects in current directory... [13:26:38]: Created new folder './fastlane'. [13:26:38]: Detected an iOS/macOS project in the current directory: 'Red.Goose.xcworkspace' [13:26:38]: ----------------------------- [13:26:38]: --- Welcome to fastlane 🚀 --- [13:26:38]: ----------------------------- [13:26:38]: fastlane can help you with all kinds of automation for your mobile app [13:26:38]: We recommend automating one task first, and then gradually automating more over time [13:26:38]: What would you like to use fastlane for? 1. 📸 Automate screenshots 2. 👩✈️ Automate beta distribution to TestFlight 3. 🚀 Automate App Store distribution 4. 🛠 Manual setup - manually setup your project to automate your tasks ?
Fastlane will ask four ways to install itself.
We’ll go with the fourth option–manual setup–for the purpose of this article.
During installation, Fastlane will ask a few more things.
enter to continue setting up with defaults.
Now you’ll see a new directory called
fastlane inside your project containing the following two files:
red-goose$ ls Gemfile Pods goose.red.xcworkspace Gemfile.lock README.md goose.redTests fastlane goose.redUITests Podfile goose.red Podfile.lock goose.red.xcodeproj $ cd fastlane && ls 1. Appfile 2. Fastlane
We will be using the
Fastlane file to specify the lanes or the tasks that our iOS app is going to need to build with and leave the
Appfile untouched because for environment variables we will use the
Let’s start on the lanes for our Fastlane setup.
Step-3: Stubbing out the lanes
On your Fastlane file copy the following contents:
platform :ios do desc "Create app on the Developer Portal and App Store Connect" lane :create do create_app_online # Or produce end desc "Sync sign using" lane :sign do create # The sign lane above. sync_code_signing # Or match end desc "Generate the binaries" lane :build do sign # The sign lane above. end desc "Upload to App store" lane :release do build # The build lane above. # build_app(workspace: "goose.red.xcworkspace", scheme: "goose.red") # upload_to_app_store(skip_metadata: true, skip_screenshots: true) end end
Notice that each lane has a single responsibility and is chained to the next lane in a sequence.