Update Note : Lyndsey Scott updated this tutorial for Xcode 10.1, Swift 4.2, Ruby 2.5.1 and fastlane 2.112.0. Satraj Bambra wrote the original.
It's the glorious moment: You've been greeting days, weeks, or maybe months to build an app, and it's finally ready to share with the world. All you have to do is send it to the App Store. How hard can it be, right?
Cue mountains of grunt work: capture tons of screenshots, add your app to the Apple Developer and App Store Connect sites, upload binary and metadata and other thoughtless work! Argh!
Isn't there a better way? If you could just run a single command that took all of your screens on all your supported devices, each supported language automatically. If there was only one command to upload these screens, add your app to Apple's developer sites and submit everything. Think about all the time you want to save!
Well, you have happiness. :] Thanks to the Creator Felix Krause and Leaders Josh Holtz is a tool to do all this and more! It is called fastlane ! In this tutorial you will learn how to use fastlane to deploy an app to the App Store. It is safe to be your new best friend. Even Google's buddied up with fastlane by acquiring it in 201
First download the materials for this tutorial at the top or bottom of this page using Download the materials button, then save them in an appropriate location.
This tutorial is a trial app, mZone Poker is a poker calculator for No Limit Texas Hold 'em em tournaments.
Open the mZone project in Xcode to build, run and check it out.
<img src = "https://koenig-media.raywenderlich.com/uploads/2015/09/mzonestarter-278×500.gif" alt = "mZone starts  Setting up fixedlane
The fixedlane tool is a collection of Ruby scripts so you must have the correct version of Ruby installed. Chances are that your operating system comes with Ruby 2.0 by default, but you can confirm if this is the case by opening Terminal and enter:
If it is not installed, the easiest way to do this via Homebrew is a packet processing for macOS.
Install Homebrew by entering this Terminal command:
/ usr / bin / ruby - e t "$ (curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then you install Ruby using:
brew update && brew install ruby
bryggelink - overwrite ruby and / or open a new Terminal session if Homebrew instructs you.
You also need Xcode Command Line Tools (CLT) . To make sure they are installed, enter Terminal:
xcode-select - install
If Xcode CLT is already installed, you get this error:
xcode-select: error: command line tool is already installed, use "Software Update" to install updates . If not, continue the installation when prompted.
Now you're ready to install fastlane! Enter the following command to do so:
sudo gem installation -n / usr / local / bin fastlane --verbose
If you prefer to use Homebrew, type the following command:
brew cask install fastlane
: With El Capitan, OS X System Integrity Protection also introduced as Rootless which prevents users from having root access.
/ usr / local / binis still writable, so you install fastlane there.
Once you have entered your system password, you will see a number of activities in Terminal indicating that the installation is in progress. This may take a few minutes, so grab some coffee, walk your dog or brush up on your zombie-fighting tactics. :]
When the installation is complete, you are ready to set up the fixedlane in the project.
To work with his magic, the fastlane brings the following set of tools under one roof:
- produce creates new iOS apps in both the App Store Connect and the Apple Developer Portal.
- cert automatically creates and maintains IOS code signing certificates.
- sigh creates, renews, downloads and repairs commission profiles.
- still image automates taking localized screens of your iOS app on all devices.
- frameit sets screenshots to the correct device frames
- gym builds and packs your iOS apps.
- supplies upload screenshots, metadata and your apps to the App Store.
- pem automatically generates and renews your push message profiles
- space ship is a Ruby library that accesses the Apple Developer Center and the App Store Connect API.
- pilot automates TestFlight distributions and manages beta testers.
- boarding invites beta testers
- match synchronizes certificates and commission profiles across your entire team, using Git.
- scan runs tests on your apps.
You are using several of these tools today. Enough with the theory for now - it's time to put this tutorial in gear and go into the fast pace!
Add fixedlane to the project
Open Terminal and
cd in your mZone startup project. For example, if you added the mZone_Sample_Project folder to your desktop, enter:
cd ~ / Desktop / mZone_Sample_Project / mZone
To put the mZone start project as a work directory.
To initialize the fastlane.
If sometimes, the fix tells you to update to a newer version, but to run
sudo gem update fastlane the output that it is "Nothing to update," perhaps the Ruby leader you are using is not "t updated. Run
pearl sources - add https://rubygems.org/ to install Ruby Gems since it is likely to produce the latest information.
After some output, fastlane will ask: "What do you want to use fastlane for?"
Although the fixedlane "recommends [s] automates a task first," you implement several automated actions during this single tutorial, then enter 4 to start manual setup. Read the output and press Enter when prompted.
Back in the folder mZone you will find a few new things: Gemfile which includes fixed line as a project addiction and a fixedlane folder containing:
- Appfile : stores the app identifier, your Apple ID, and other identifying information that fastlane needs to configure your app.
- Fastfile : controls the paths you want to create to invoke fixed actions.
Open Fastfile in a text editor of your choice, disable smart quotes if the text editor supports them, and then replaces the contents of the file with:
default_platform ( : ios) platform: ios does # 1 desc "Create app at Apple Developer and App Store Connect sites" # 2 path: create_app does # 3 Produce end end
If you've never seen Ruby before, this may look like gibberish to you. Here's what this code does:
- Provides a description of the path .
- User produces to add the app to both the developer portal and the App Store Connect. (19459000) Uses this file
Woohoo! You have now created your very first lane .
apple_dev_portal_id ("[[APPLE_DEVELOPER_ACCOUNT_USERNAME]]") itunes_connect_id ("[[APP_STORE_CONNECT_ACCOUNT_USERNAME]]")
Then change each user name holder with their respective user name.
Save Application before closing.
Create your app
Open Terminal inside your project folder and type:
create_app the path that you just created.
You should see something like this:
At the top of that output, fastlane suggests that you go ahead of your fastlane command with "bundle exec" to start faster faster in the context of the pearl pile. Continue, you can do it.
Enter the App Store. Connect to a password if prompted. If your developer portal has multiple layers, enter the number corresponding to the team you want to use for the mZone Poker app.
Finally, producing will ask you to enter bundle ID. Time to make one!
The bundle identifier must be different from each other bundle identifier ever used in the App Store Connect. Try entering a unique bundle identifier using the following format:
com.mZone-Poker. [Insert your email address minus “@” and “.”]
If the bundle identifier has already been taken, edit it and try again until you have submitted a unique ID.
Then, when asked to submit an app name, it must also be unique. Try using the following format:
mZone Poker [Insert your email address minus “@” and “.”]
App names cannot be longer than 30 characters, but abbreviated as needed.
If your App Store Connect account has multiple layers, enter the number that corresponds to the team you want to use.  If you receive errors indicating that there is a problem with your Apple Developer account (for example, if you need to accept a new program agreement), you must correct the problem and run
If the App name is unavailable, the process will end with an error. Run
produce again, enter your Apple ID and the same Bundle ID you just created, then flex your creative muscles to create a unique ID or return to the top of this paragraph and repeat. We know, frustratingly, but we are sure that you will break the infinite loop!
Log in to the Apple Developer Center and the App Store Connect. Voilà! Your app has already been added to both. How cool is that? :]