eHarmony Engineering logo

Fastlane iOS Release Automation

Christopher Truman

April 29, 2016

At eHarmony, we aim to deploy rapidly to our mobile platforms. Lately it’s become increasingly complicated to release all our native mobile applications both domestically and internationally. In the past we relied on custom tools to automate the process, which added development overhead. Now we’ve adopted Fastlane tools; with just a few lines of code, we’ve automated many time-consuming tasks. We’re performing rapid and reliable unit tests that hook into Slack, so that teams see the results right away. We can also easily submit multi-locale and language releases to the App Store. Check out my post for more details… Christopher Truman

To provide reliable tooling for our release processes, I worked with our team to adopt Fastlane (fastlane.tools). Fastlane is a suite of tools that can accomplish many of the tasks associated with iOS app development. This project handles all the details of interacting with Apple tools and other APIs, so that we can focus on development.  Our goal at eHarmony is to move fast, while ensuring quality.  I believe automation, testing, and tools are the keys to achieving speed AND quality.  This post will describe the ways we are currently using Fastlane to accomplish this goal.

Release Notes – Internationalization

We have translated our App Store description into several languages and have to submit release notes in each language. Previously this was a manual process requiring someone to copy and paste this text 20+ times. Now, with a simple Fastlane script we can automate it and prevent human error.

desc "Update What's New text for the latest version of eH on iTunes Connect. Edit the file at fastlane/changelog.txt to change the text."
lane :release_notes_eh do
set_changelog(app_identifier: "com.YourBundleID")
end

Internationalization is a complicated process.  This is especially true when it comes to the iOS App Store.  As eHarmony spreads into new countries and supports new languages, the amount of screenshots, release notes, and app descriptions that we have to upload multiplies.  We also have to support different screen sizes and resolutions in our screenshots.  Uploading and producing these all manually is a huge pain. Many teams are using Fastlane to automatically take screenshots in different languages and submit them to Apple.   As we start supporting more languages, we will be doing the same.

Unit Tests

We have some test coverage on our core library that contains all our business logic. Fastlane allows us to quickly and simply run these tests with human readable output. We run this test whenever we commit to our shared libraries to confirm that all code that makes it into a production branch has passed the tests.

lane :test do
scan(scheme: "SinglesShared")
end

 

Internal Testing – HockeyApp

We are constantly sending builds to our QA, UX, and Product teams for testing and feedback. We often have multiple releases in development at once. We use HockeyApp to host our builds. This lane simplifies the process of building and uploading.

desc "Submit a new eH Beta Build to HockeyApp"
lane :hockey_eh do
  gym(scheme: "Singles")
  hockey(api_token: "YOUR TOKEN HERE")
end

 

External Testing – TestFlight

The process of submitting to the App Store can be a pain and take time. We have set up a lane that bumps the version of our app, builds, and submits it to iTunes Connect. Even more helpful, it notifies the team once the build has finished processing so we don’t have to wait or send a notification manually.

desc "Submit a new eH Beta Build to Apple TestFlight"
lane :testflight_eh do
  increment_build_number
  gym(scheme: "Singles")
  pilot(ipa: "Singles.ipa")
end

 

Slack Notifications

Slack is the new hotness when it comes to corporate communications.  I also hear that bots are a new exciting thing.  So we combine them both to achieve super awesomeness and effective communication.  Using Slack’s web hooks, Fastlane can easily send messages to specific channels when a lane completes with a success or failure. You can configure different messages based on which lane you are running and include other pertinent info like build URLs, specific errors, and unit test reports. We use ‘after_all’ to send a notification every time a lane succeeds and customize the message:

after_all do |lane|
  notify "Success"
  if (lane_context[SharedValues::BUILD_NUMBER])
    slack(
    message: "Successfully deployed " + lane_context[SharedValues::LANE_NAME] + " build to Test Flight - Build #" + lane_context[SharedValues::BUILD_NUMBER]
    )
  elsif (lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK])
    slack(
    message: "Successfully deployed " + lane_context[SharedValues::LANE_NAME] + " build to HockeyApp\n URL: " + lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK]
    )
  end
end

unit_test_hockey-success

We use ‘error’ to handle any type of error and notify the appropriate Slack channel:

error do |lane, exception|
  notify exception.message
  slack(
  message: exception.message,
  success: false
  )
end

unit test failure These examples just barely scratch the surface of what is possible with these tools.  I encourage you to view this repository that contains example of how companies like Twitter, Timehop, and Fastlane itself are using these tools (https://github.com/fastlane/examples). These examples show how this tool can be used as an excellent abstraction layer for any type of automation. Fastlane is also starting to develop tools for Android so that you can unify your automation scripts even if you develop cross platform.   At the time of writing this, Fastlane contains over 160 custom actions to allow you to simplify and automate your development process.  I am in the process of contributing a new action to integrate with JIRA here. Our team loves this tool and are planning to contribute back to the project any way we can.

I hope I have shown how powerful this tool can be. With a few lines of code we are able to quickly and simply automate all sorts of tasks. This saves developer time, ensures consistency and accuracy, and is just plain cool.