Build mobile cross-automation with Fastlane

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

</br> 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.

</br> CircleCI YAML configuration example

# Configuration: https://circleci.com/docs/configuration
# More info: https://circleci.com/docs/ios
machine:
  timezone:
    # Timezone: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
    Europe/Lisbon
  environment:
    # CocoaPods versions greater than 0.34 require
    # your terminal to be using UTF-8 encoding.
    LANG: en_US.UTF-8
  xcode:
    version: "6.4"
dependencies:
  pre:
    - brew update
  override:
    - sudo gem install fastlane
test:
  override:
    - fastlane ios test setup:true slack:true
deployment:
  beta:
    # Beta release
    branch: master
    commands:
      - fastlane ios beta slack:true
  release:
    # AppStore release
    # RegEx: v1, v1.2, and v1.2.3 (and so on) all match.
    tag: /v[0-9]+(\.[0-9]+)*/
    commands:
      - fastlane ios appstore slack:true

</br> Bitrise YAML configuration example

format_version: 1.0.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

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

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

workflows:
  beta:
    description: |-
      You can use this workflow by running: bitrise run beta
    steps:
    - timestamp:
        outputs:
        - UNIX_TIMESTAMP:
        - ISO_DATETIME:
    - script:
        title: Beta release
        inputs:
        - content: |-
            #!/bin/bash
            fastlane ios beta

</br>

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.

Fastlane

Stay tuned for 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.

#product-development #the-forge

Ricardo Pereira

More posts

Share This Post

Right Talent, Right Time

Turnkey technical teams and solo specialists
when you need them for greatest impact.

Work with us