Building iOS apps with fastlane

Setting up an iOS app using fastlane

In this tutorial, we'll guide you how to set up automated builds for your iOS application using fastlane. To do that, Nevercode expects nothing more than a Fastfile in your repository.

This guide covers how to:

Add a new app

  1. Click Add a new app on Nevercode dashboard.
Nevercode dashboard

Nevercode dashboard

  1. Choose whether to add your application via supported providers using OAuth or add it manually using the other available authentication methods.

Define the lane to be built

After specifying app repository, Nevercode takes a first look at it by listing the branches in this repository. The next step for you is to select the branch you want Nevercode to scan for projects.

  1. Select a branch from the dropdown that Nevercode should scan. Note that you can change the branch later if needed.
  2. Click Scan branch.
    Nevercode scans the repository from the specified branch. This includes cloning the repository, looking up the available Fastfiles and listing the pre-configured lanes. All this can be monitored in real time via the live log window in your browser.
  3. Once scanning the branch has finished, choose the lane which will be executed as the main build step by Nevercode.
  4. Finalize the setup by checking the appropriate build options and click Save and start build.
Build configuration

Build configuration

Handle external dependencies

Nevercode does not automatically install CocoaPods, Carthage or any other external dependencies for fastlane projects. Please use fastlane's built-in actions, such as cocoapods and [carthage],( to gain control of that.

Sign code

To perform code signing on your iOS app, you can either follow the best practices laid out in fastlane docs, or you could also make use of Nevercode's standard code signing methods.

When invoking Match from the Fastfile, keep in mind that you need to grant access to the credentials repository and expose the Match passphrase during the build. Both can be securely achieved thanks to the well designed environment variable support of fastlane and Nevercode's support for several SSH keys for authentication.

In your app settings on Nevercode, navigate to the Environment tab to manage environment variables and files:

  • Match passphrase can be defined as a MATCH_PASSWORD environment file — this will be automatically detected by fastlane and used to decrypt the credentials repository.
  • You can upload the SSH key for cloning the credentials repository as an environment file, i.e. MATCH_SSH_KEY. All environment files whose variable name has the suffix _SSH_KEY will be automatically added to the SSH agent and will be ready for use during the whole build process.
Using environment variables and files to grant access to credentials

Using environment variables and files to grant access to credentials

Run tests

Testing on Nevercode with fastlane is 100% automatic. By default, scan is used to invoke the test run, but you can easily swap it out for any other lane that you have configured for your test runs. Test results are automatically collected and you don't need to do anything to convert the results from one format to another or place them in a special location on the build machine.

Configuring fastlane scan

Configuring fastlane scan

In case you wish to run tests as part of the main build step, we suggest that you use Trainer to generate reliable JUnit results from the test run and put the results in a directory where we can discover them:

trainer(output_directory: ENV["NEVERCODE_XUNIT_RESULTS_DIR"])

Publish your build artefacts

You can use either fastlane to take care of artefact distribution or choose from a number of Nevercode's own integrations.

To make build artefacts available on Nevercode and use it for build distribution, we will check the $GYM_OUTPUT_DIRECTORY folder for artefacts. If this folder does not exist, we will look for *.ipa files in project directory.

Manage build versions

To make your build version management easy, Nevercode exports the NEVERCODE_BUILD_NUMBER environment variable that you can use in your build script. For instance, your could make use of it within increment_version_number action to define a new version for each build.

Building iOS apps with fastlane

Setting up an iOS app using fastlane