Using Fastlane for Continuous Delivery of iOS Apps

  November 16, 2016

Continuous *everything* has quickly become one of the most crucial backbones of mobile DevOps workflow. Many of today’s mobile developers use continuous integration to build, test and deploy their apps, games and even web apps. The process is typically scripted and configured so that all steps take place automatically and source code is stored on the repository (Github, some local one etc).

In this article, we take a look at how mobile continuous delivery and continuous integration works for iOS app development and testing. We’ll also take a look at Fastlane and how mobile devs can get the best out of it.

The Modern Mobile DevOps

The companies with Mobile DevOps approach and culture has adopted various principles that evolve and new tools are brought into the process. App development, continuous delivery and integration tools are optimally adopted when automation is used for various phases of product development: build, testing, deployment and monitoring. Don’t miss our free XCTest framework to boost your iOS app testing.

7 process steps for better mobile devops

The modern mobile DevOps includes 7 different steps that are used across and inside organizations as part of their daily tasks. In this context, it’s highly crucial that tools and methods used are aligned and integrated with the overall goal. And especially when it comes to considering what tools are used, how those fit together and enable seamless tool flow from planning to production.

Test automation is a critical part of the flow and also important for iOS app development as it enables a process to be highly iterative, repeatable, and robust. Automation is actually an enabler for continuous everything, in each step of the process.

Fastlane for Continuous Delivery of iOS Apps

As there are plenty of Mobile DevOps tools and all have different use cases and sometimes those tools can be overlapping each other in the overall Mobile DevOps process, we love to experiment and also use different tools and methods here at Bitbar for our internal Mobile DevOps workflow. And frankly, there are many when it comes to using these tools in our internal process and automation. One of those tools that I find handy in terms of iOS automation is Fastlane.

Fastlane for Continuous Delivery of iOS Apps

It is one good optional tool/set of practices to use as part of your iOS app development. It can help in an effort to automate your beta deployments/releases for both Android and iOS apps. At least from my point of view, the most significant help that it can offer is in code signing and dealing all tedious things around it.

Fastline provides several interesting and useful components/tools for making the continuous delivery environment smoother for the actual app development and getting all the assets ready for the release.

The features/components in Fastlane that are relevant to continuous delivery are as follows:

  • deliver uploads screenshots of your application, all relevant metadata and required binaries to iTunes Connect. This feature can be used to submit an iOS application to App Store review. Typically, this feature is used when your tests are passed and you have the release version of your app ready.
  • snapshot generates localized iOS screenshots for different device types and languages for the App Store and can be uploaded using deliver.
  • frameit allows its users to place a device farm around the screenshot. This can be done with a single command and it produces highly usable screenshots of the app with the actual device mockup.
  • sigh can fully manage all aspects of provisioning profiles. Using one command user can create, renew, and fix provisioning profiles. It supports store releases, Ad-Hoc, Development and Enterprise profiles.
  • produce set a created iOS app on Developer Portal and/or iTunes Connect.
  • cert is a dedicated feature for code signing. With ‘cert’ users can quickly create code signing identities for development or release distribution. ‘cert’ also allows the use of local certificates (if the user has installed any).
  • scan makes it easier to run iOS tests on Xcode simulator or any connected devices on your local environment.
  • gym builds and packages an iOS app. With ‘gym’ it is easy to generate a signed .ipa file and push that for real device testing.

Let’s look at a few examples. First, using ‘gym’ user can quickly build and package the app for tests. Before the ‘gym’ is executed the xcodebuild can be used to clean up and to package distribution builds, this can be used to create builds without actual dependencies to provisioning:

xcodebuild clean archive -archivePath build/MyApp \
                         -scheme MyApp
xcodebuild -exportArchive \
           -exportFormat ipa \
           -archivePath "build/App.xcarchive" \
           -exportPath "build/App.ipa" \
           -exportProvisioningProfile "ProvisioningProfileName"

The ‘gym’ can include with all details about the build and there are plenty of parameters that can be used in the context.

  # Build the app
    scheme: "#{options[:scheme]}",                         // e.g. scheme:
    configuration: options[:configuration],                // configuration: app.build_configuration,
    provisioning_profile_path: options[:profile],          // provisioning_profile_path: /Users/name/...
    codesigning_identity: options[:codesigning_identity],  // codesigning_identity: "xxx"
    export_method: options[:export_method]                 // export_method: "enterprise", "adhoc" etc

TIP! It’s highly recommended that developers using Fastlane (and those who use the above examples) make sure their xcodeproj is at least 1.3.2 (or newer).

Different Environments and Tools for Different Use Cases

Now, it really depends if you are building an app for internal tests or building an app for release distribution. If you build an app for release distribution, Fastlane is a great tool that can get things done super fast and help you to ensure everything is in place before you actually publish the app.

If you use Fastlane during the development and preferably together with continuous integration (e.g. Jenkins) Fastlane can also offer some nice benefits.

For debugging and further developing the app you need full-blown Xcode environment up and running. You also need the same if you run tests internally on simulators or devices connected to your machine.

Enjoy Fastlane!