Skip to content

Latest commit

 

History

History
209 lines (135 loc) · 7.51 KB

GUIDE.md

File metadata and controls

209 lines (135 loc) · 7.51 KB

From manual to fully automatic app deployments

This guide will help you set up Continuous Deployment for your iOS project.

It will help you set up all needed build tools. I tested everything with a fresh Yosemite installation.


InstallationSetting upJenkinsExample ProjectHelp


Notes about this guide

If you don't want to use sudo, you can follow the CocoaPods Guide of a sudo-less installation.

Installation

Requirements

  • Mac OS 10.9 or newer
  • Ruby 2.0 or newer (ruby -v)
  • Xcode

Xcode

Additionally to an Xcode installation, you also need the Xcode command line tools set up

xcode-select --install

You don't have to use homebrew to install the dependencies. It's the easiest way to get started.

If you don't have homebrew already installed, follow the guide on the bottom of the official page.

brew doctor && brew update

xctool (optional)

brew install xctool
sudo gem install nokogiri

This can be a pain sometimes, in case you're running into problems, take a look at the official installation guide.

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

sudo gem install fastlane

Setting up fastlane

Before changing anything, I recommend commiting everything in git, in case something goes wrong.

Get it up and running

When running the setup commands, please read the instructions shown in the terminal. There is usually a reason they are there.

fastlane will create all necessary files and folders for you

fastlane init
  • Confirm until you get asked for your App Identifier
  • Enter the App Identifier (Bundle Identifier) of your project
  • Enter your Apple ID: The username, you enter when you login on iTunes Connect
  • If you haven't already used deliver:
  • Confirm with y to start the setup for deliver
  • If your app is already in the App Store, confirm with y to automatically create a configuration for you. If it's not yet in the store, enter n
  • If you haven't already used snapshot:
  • Confirm with y if you want your screenshots to be created automatically
  • If you want to sigh to download, renew or create your provisioning profiles, confirm with y

That's it, you should have received a success message.

What did this setup do?

  • Created a fastlane folder
  • Moved existing deliver and snapshot configuration into the fastlane folder
  • Created fastlane/Appfile, which stores your Apple ID and Bundle Identifier
  • Created fastlane/Fastfile, which stores your deployment pipelines

The setup automatically detects, which tools you're using (e.g. deliver, CocoaPods, xctool)

Individual Tools

Before running fastlane, make sure, all tools are correctly set up.

For example, try running the following (depending on what you plan on using):

All those tools have detailed instructions on how to set them up. It's easier to set them up now, than later.

Enable Instruments CLI

If you want to use snapshot, please follow this step, to authorize snapshot running using fastlane.

Configure the Fastfile

First, think about what different builds you'll need. Some ideas:

  • New App Store releases
  • Beta Builds for TestFlight or HockeyApp
  • Only testing (unit and integration tests)
  • In House distribution

Open the fastlane/Fastfile in your preferred text editor and change the syntax highlighting to Ruby.

Depending on your existing setup, it looks similar to this (I removed some lines):

before_all do
  # increment_build_number
  cocoapods
  xctool "test"
end

lane :test do 
  snapshot
end

lane :beta do
  snapshot
  sigh
  deliver :skip_deploy, :beta
  # sh "your_script.sh"
end

lane :deploy do
  snapshot
  sigh
  deliver :skip_deploy, :force
  # frameit
end

lane :inhouse do
  # insert your code here
end

after_all do |lane|
  # This block is called, only if the executed lane was successful
end

error do |lane, exception|
  # Something bad happened
end

You can already try running it, put a line (say "It works") to the :inhouse lane and run

fastlane inhouse

You should hear your computer speaking to you, which is great!

A list of available actions can be found on the fastlane project page.

Update the Fastfile

Now it's the time to adapt the Fastfile to implement your deployment pipeline. You should use increment_build_number when you want to upload builds to iTunes Connect (Activate incrementing build numbers)

Add as many lanes as you want and test them by running fastlane [lane name].

Use your existing build scripts

sh "./script.sh"

This will execute your existing build script. Everything inside the " will be executed in the shell.

Create your own actions (build steps)

If you want a fancy command (like snapshot has), you can build your own extension very easily using this guide.

Jenkins Integration

(or any other Continuous Integration system)

Deploying from your own computer isn't cool. You know what's cool? Letting a remote server publish app updates for you.

Everything you did in this guide, was stored in the filesystem in configuration files, which means, you have everything you need in version control. Add

fastlane appstore

as a build step on your server, and you're good to go.

Even better Jenkins integration

For a more detailed CI-setup, which also shows you test results and the latest screenshots, take a look at the Jenkins Guide.

Deploy strategy

Tips about when to deploy can be found in the fastlane Jenkins instructions.

Example project

Take a look at a project with fastlane already set up: fastlane-example

Help

  • If something is unclear or you need help, submit an issue.
  • I'm available for contract work - drop me an email: [email protected]