BAM

How to deploy an iOS app to Tesflight in 5 minutes with Fastlane

Requirements:

  • you have some prior knowledge about codesigning an iOS app
  • you have an Apple developer account, enrolled in the Developer program (you have access to iTunes Connect)
  • Mac OS 10.9 or newer with XCode installed
  • Ruby 2.0 or newer (check ++code>ruby -v++/code>)

What is Fastlane

Codesigning and deploying an app to the Apple Store is a fastidious, time-consuming, error-prone process.
See this entry in Stack-Overflow just to get an idea. ;)

Don't worry, here comes Fastlane!

fastlane_text.png

Fastlane is a toolbox (written in Ruby) that will allow you to automate all these tedious process.

Install it

You need the Xcode command line tools set up

++pre>++code>xcode-select --install
++/code>++/pre>

If you have not used the command line tools before, you'll need to accept the terms of service.

++pre>++code>sudo xcodebuild -license accept
++/code>++/pre>

Install the gem and all its dependencies (this might take a few minutes).

++pre>++code>sudo gem install fastlane --verbose
++/code>++/pre>

Don't worry if it takes a few minutes. A lot of goodness is installing.

Try it out

You now have access to a lot of tools, called actions.
An action is designed to help you automate a single task.

For instance, let's try the action ++code>cert++/code>.
Run anywhere in a terminal:

++pre>++code>++code class=" language-shell">$ cert
++/code>++/code>++/pre>

You will be prompted for your Apple Id and password.
Fastlane will use its credentials manager to store it in your keychain.

Yes. ++code>cert++/code> is automatically checking installed certificates on your machine
and creating one if it couldn't find any.

Now try to run:

++pre>++code>++code class=" language-shell">sigh  
++/code>++/code>++/pre>

You will be asked for a bundle identifier. Try to give one you've already used.
Yes. ++code>sigh++/code> is automatically creating/downloading provisioning profiles from your
developer account for the specified app.

There is a lot of useful actions bundled up in Fastlane.

++code>produce++/code> is used to create an App Id in the developer member cender and/or iTunes Connect.
++code>cert++/code> is used to create certificates.
++code>sigh++/code> is used to manage provisioning profiles
++code>gym++/code> is used to build and archive your app.
++code>pilot++/code> is used to upload an ipa to testflight
++code>deliver++/code> is used to manage the metadata on iTunes Connect.
++code>pem++/code> is used to manage your push notification profiles

And there are many more! You'll see them all if you run:

++pre>++code>++code class=" language-shell">fastlane actions  
++/code>++/code>++/pre>

If want to know more about a specific action, you can run:

++pre>++code>++code class=" language-shell">fastlane actions [action]  
++/code>++/code>++/pre>

or you can check the docs.

Orchestrate the magic in lanes

Now, what you'd probably want to do is put some of these actions together in a process.

For instance, to deploy an app to Testflight from scratch, you'd need to have a certificate, a provisioning profile. Then you'd archive your app and finally you'd upload it to Testflight.
Your process would be ++code>cert++/code>, ++code>sigh++/code>, ++code>gym++/code> and then ++code>pilot++/code>.

Well, with Fastlane, you can put actions together in a lane.
In a folder where you have an Xcode project, run:

++pre>++code>++code class=" language-shell">$ fastlane init
++/code>++/code>++/pre>

It will create your app on the Apple developer portal and on iTunes Connect,automatically! It is actually using the action ++code>produce++/code> to do so.
It will also generate a ++code>fastlane++/code> folder with an ++code>Appfile++/code> and a ++code>Fastfile++/code>.

The ++code>Appfile++/code> stores useful information that are used across all ++code>fastlane++/code> tools like your Apple ID or the application Bundle Identifier, to deploy your lanes faster and tailored on your project needs.
Find out more in the docs

In the ++code>Fastfile++/code>, you can create lanes, to orchestrate all the actions you'd want to use.

For instance, you could define:

++pre>++code>++code class=" language-ruby">lane :beta do  
 # Put any actions you'd want here, for instance:
 # Use cert to generate a certificate
 cert
 # Use sigh to download or generate a provisioning profile
 sigh
 # Use gym to archive your app
 gym
 # Use pilot to upload your app to testflight
 pilot(distribute_external: false)
end  
++/code>++/code>++/pre>

Then run

++pre>++code>++code class=" language-shell">$ fastlane beta
++/code>++/code>++/pre>

and let the magic happen!

Where to go from here

Développeur mobile ?

Rejoins nos équipes