Deployment Automation in iOS using Fastlane

What is Continuous Delivery?

Continuous Delivery is a design practice used in software development to automate and improve the process of software delivery. Before fastlane, iOS Developers did not have this privilege for automating the process for deploying apps on the iTunes store.

Why Fastlane?

Basically you want to deploy updates more often to the App Store to make it less painful and increase the quality of your app. But it’s a tedious, repeating task.
Using fastlane and its tools, you run one command to deploy an update of your app to the App Store.

What Fastlane contains?

Fastlane is a collection of ruby scripts that will cover the most usual tasks required when submitting a new iOS app or update to the App Store:

deliver: Upload screenshots, metadata and your app to the App Store using a single command
snapshot: Automate taking localized screenshots of your iOS app on every device
frameit: Quickly put your screenshots into the right device frames
PEM: Automatically generate and renew your push notification profiles
sigh: Because you would rather spend your time building stuff than fighting provisioning
produce: Create new iOS apps on iTunes Connect and Dev Portal using the command line
cert: Automatically create and maintain iOS code signing certificates
codes: Create promo codes for iOS Apps using the command line

Jenkins, Cocoapods, etc:

The suite sports integration with Jenkins and other third-party tools such as CocoaPods, and xctool, and allows to define multiple lanes which address different deployment targets such as App Store, TestFlight Beta, and testing. We can show the output directly in the Jenkins test results.

Steps for integration

INSTALLATION:
0. Requires Mac OS 10.9 or newer, Ruby 2.0 or newer (ruby -v), and Xcode
1. Check Ruby version (Ruby 2.0 or newer is required) :- ruby -v
2. Check if Xcode command line tools are setup :- xcode-select –install
3. Install HomeBrew (http://brew.sh/) :- ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
4. Install Phantom JS :- brew install phantomjs
5. Install fastlane :- ​sudo gem install fastlane

Note: Do read the logs during installation, these will help you in case you hit a roadblock.

SETUP:

1.  cd [your_project_folder]
2. Write command
fastlane init

A new folder fastlane will be created in your project directory.
3. Confirm. Enter your “App Identifier”
Created new file at path ‘./fastlane/Appfile’. Edit it to manage your preferred app metadata information.

4. Enter iTunes Connect account credentials
5. Confirm with ‘Yes’ as per instructions there. Initial steps help you configure for ‘deliver’ and ‘snapshot’
Successfully created new Deliverfile at ‘./fastlane/Deliverfile’
Successfully created new Snapfile at ‘./fastlane/Snapfile’

6. Confirm with Yes for ‘sigh’. This will help you create/renew your provisioning profiles automatically in one step.
7. A list of all the enabled and disabled features will be displayed.
8. Successfully finished setting up fastlane.

Created new file ‘./fastlane/Fastfile’. Edit it to manage your own deployment pipelines called lanes.

EXAMPLES:

1.  Install Jenkins : brew update && brew install jenkins
From now on start Jenkins by running command: jenkins
2. To build an ipa in one step using fastlane: ipa build
3. To generate and download your App Store provisioning profile.
sigh

sigh will store the generated profile in the ./fastlane folder.

4. To upload a new build to TestFlight use: deliver :beta
5. You define a lane like this:

lane :appstore do
increment_build_number
cocoa pods
xctool
snapshot
sigh
deliver
frameit
sh "./customScript.sh"

slack
end

Now, to launch the appstore lane run:
fastlane appstore

How stable is this?
fastlane uses a combination of official Apple API and frontend scripting using a headless JavaScript browser.

Advantages of Fastlane

The main advantage is to just save so much time each time you release an update or new app. It’s something iOS developers have to do by themselves.
a. Don’t rely on one person releasing updates
b. Save days of preparing app submission, uploading screenshots and releasing the app
c. Increase software quality and reaction time with more frequent and smaller releases
d. Deploy from any computer, even your remote server
e. Store everything in git. Never look up build commands again

Using fastlane and its tools, you run one command to deploy an update of your app to the App Store.

References:

https://fastlane.tools/

https://github.com/KrauseFx/fastlane

Leave a Reply

Your email address will not be published. Required fields are marked *


− 2 = two

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>