Join CTO Moataz Soliman as he explores the potential impact poor performance can have on your bottom line. 👉 Register Today

ebook icon

Engineering

General

How We Automate Our iOS Workflow at Instabug Using CircleCI

At Instabug we build an SDK for mobile apps. Building an SDK often means that most tools created for automating tasks around development and deployment of iOS apps don't work for us, so we usually need to develop our own bespoke solutions.

To increase our productivity and keep thing moving fast, we like to automate things. One crucial component of automating many parts of our workflow is continuous integration.

This post goes through what our workflow is and how we automate it using CircleCI.

Overview

With CircleCI 2.0, we can create multiple jobs under one workflow, with the ability to define dependencies between jobs and run some of them in parallel, which is great.


Our workflow has 4 jobs:

  1. Running unit tests, integration tests and Danger
  2. Running UI tests and static analyzer
  3. Generating binary
  4. Releasing the SDK

Let's go through each one in detail.

1. Running Unit Tests, Integration Tests and Danger


First, we install all gems used by our project, like Danger and fastlane either by restoring the cache of a previous install, or by doing a fresh install.

We then run our unit tests. Due to how our project is structured, we have around 15 framework targets, with a separate test target for each. To run all our unit tests at once, we have an AllUnitTests scheme that runs all test targets.

After running our unit tests, we run Danger, which is a great tool to automate some of the chores around code reviews. Here's what we use it for right now:

  1. Enforce having a description and a link to a Jira issue for all pull requests.
  2. Ensure that all pull requests that add new user-facing strings add localized versions of those strings.
  3. Run xcov to generate a report about our tests coverage, and post it as a comment on the pull request.
  4. Ensure that all pull requests that modify any UI file run UI tests before merging the pull request.


Last steps of this job is to run our integration tests, which is just a test target with a similar configuration to our unit test targets.

This job runs on every pull request, so we have to make sure it contains all the essential checks/tests, and that it also runs in a reasonable time. It currently runs in around 8 minutes, with the majority of the time going to making a clean build of the SDK for running tests.

2. Running UI Tests and Static Analyzer


This job is very similar to what we do in the first job, but it instead runs a UI tests target and the static analyzer using xcodebuild analyze.

This job only runs on master, and fix/release branches, so we're okay with it taking a bit longer to run. It currently finishes in around 40 minutes and runs in parallel with the first job. It can also be run on demand on any pull request regardless of its branch by mentioning a simple GitHub bot we wrote that uses the CircleCI API to trigger a specific job.

3. Generating Binary


After the first two jobs have finished, we can generate a binary of the SDK from any branch. This requires the approval of a hold from the CircleCI dashboard.

This job will install our code signing identity, which we share across the team using fastlane. It then generates both static and dynamic variants of our framework. For more on building binary framework, check our previous blog post.

It then bundles up both frameworks in a zip archive and stores it in the artifacts directory to be available for download.

4. Releasing the SDK


The last job releases the SDK to the public. It runs Unleash, our homegrown CLI app for releasing the SDK.

Unleash does the following:

  1. Create and push a new tag to our private repository.
  2. Push the updated framework to https://github.com/Instabug/Instabug-iOS/ and create a GitHub release.
  3. Publish framework to CocoaPods.
  4. Update our Carthage JSON file.
  5. Upload the release to our own API for consumption on the Instabug dashboard and website.

Conclusion

We're pretty happy with the workflow we have so far. Having a reliable CI process makes us ship with confidence, and automating our release process saves a ton of time since we release once a week.

CircleCI has been a great tool to use for our continuous integration, especially with CircleCI 2.0.

Seeing is Believing, Start Your 14-Day Free Trial

In less than a minute, integrate the Instabug SDK for iOS, Android, React Native, Xamarin, Cordova, Flutter, and Unity mobile apps