Build mobile cross-automation with Fastlane

At Whitesmith, we like to get quality right from the first time and to guarantee that we use some common practices that have gained a lot of traction over the last few years: Continuous Integration and Continuous Deployment.

Those practices help us on removing long time repetitive tasks using automation as first class citizen. They also force us writing good tests for our code.

Current iOS app deployment steps

Taking as example the iOS app of Qold® - a cold chain monitoring service, to deploy a new version we need to check these steps:

  • Run tests (including UI tests)
  • Increment build number (and version number if required)
  • Check provisioning profiles and certificates for code signing
  • Build new binary version
  • Generate release notes
  • Take screenshots for every device and every supported localisation
  • Prepare new version on iTunes Connect (and TestFlight)
  • Upload binary to iTunes Connect
  • Share with internal and external testers
  • 😩

That is a lot to handle in one day!

So we got one dilemma: How to optimize this flow?

CI&D as a Service

We knew the answer passed by using a CI&D as a Service. But then we got another dilemma: Which service to use for our CI and CD process?

Fortunately, there are many services for this task - some of them in an early stage, some others reliable but outdated for current needs. It is a tough decision, but we definitely wanted something with Android and iOS support that included fast runners/virtual machines updates.

Introducing Fastlane 1.0

The answer that we found for the two dilemmas is Fastlane. A perfect tool for cross-automation because it allows us to:

  • build one unique deployment flow with different pipelines
  • eliminate our repetitive tasks
  • publish more frequent and smaller releases
  • any person can release updates

Briefly, each flow on Fastlane is defined with a lane. It is possible to setup each lane with actions. There is a list of actions where it is possible to test, build or submit an app and much more like add_git_tag, increment_version_number, etc.

After defining a lane with the common iOS app deployment actions, the only step to do is executing the Fastlane file and nothing more 🚀. So, if you use CircleCI with the CI&D flow defined with Fastlane, then you can run the same flow on another service. You just need to guarantee the same Fastlane version on both services and you are done.

CircleCI YAML configuration example

# Configuration:
# More info:
    # Timezone:
    # CocoaPods versions greater than 0.34 require
    # your terminal to be using UTF-8 encoding.
    LANG: en_US.UTF-8
    version: "6.4"
    - brew update
    - sudo gem install fastlane
    - fastlane ios test setup:true slack:true
    # Beta release
    branch: master
      - fastlane ios beta slack:true
    # AppStore release
    # RegEx: v1, v1.2, and v1.2.3 (and so on) all match.
    tag: /v[0-9]+(\.[0-9]+)*/
      - fastlane ios appstore slack:true

Bitrise YAML configuration example

format_version: 1.0.0  

title: Template configuration.  
summary: |-  
  Template 'bitrise.yml', generated by 'bitrise init'.
  - BITRISE_APP_TITLE: "Qold-iOS-app"
  - BITRISE_DEV_BRANCH: "master"

- pattern: test**
  is_pull_request_allowed: true
  workflow: test
- pattern: "*"
  is_pull_request_allowed: true
  workflow: fallback

    description: |-
      You can use this workflow by running: bitrise run beta
    - timestamp:
        - ISO_DATETIME:
    - script:
        title: Beta release
        - content: |-
            fastlane ios beta

Fastlane + Twitter Fabric

Fastlane is now part of Fabric, a software development kit, and it is great news because it gives Fastlane a future development guaranty. Another neat part: Fastlane has started supporting Android as well.


Stay tuned on our next article about - How we setup our Qold app with Fastlane. Follow us on twitter and if you have any question, just shoot us a tweet.

Images from KrauseFx, developer of Fastlane.

Subscribe to our newsletter

Would you like to receive more posts of this kind in your Inbox?