Automate your iOS apps using Bitrise

After 4 months of using Bitrise, I felt like I should share with the community how powerful this tool is. It will be good to make a quick introduction to automation and see why exactly we need a tool for it. Let’s start with quick intro to automation in iOS and see how new tool can speed our development.

What is “automation” in software engineering?

Developing, testing and deploying needs so much attention and time for the teams. Especially, if you are making all these steps manually. You have to be careful on each step for avoiding possible mistakes. Automating the whole development/testing process increases your software product quality and saves a lot of time for you and your team.

There are some steps that you should know in the automation process, such as continuous integration, continuous delivery, and continuous deployment. Let’s explain them in a nutshell:

Continuous Integration

Let’s say your team has more than one developer who works on the same project, and you are working on Git. Assume that one developer makes a Pull Request, all the unit tests can be run on a shared computer (remote or local). After tests completed running, you know that they succeeded or failed. If the tests passed you can start making code review. Otherwise, the developer gets notified that a test has failed and something should be fixed. After everything is getting ready, code can be merged with no hassle. This process is called Continuous Integration and it helps you to automate development, tests and integration process without wasting much time.

Continuous Delivery

Each build cycle for a feature or a sprint is called Continuous Delivery. You can deliver your feature/sprint branch to integrate continuously.

If you already know Joel Spolsky who is the Co-Founder of Stack Overflow and Trello, probably you heard that he has a test called “Joel Test”. It measures the quality of software development teams to better code. “Making daily builds” is one of the important steps to better code for him. If you want to check all of the steps, click the link below:

Continuous Deployment

I think the most glamorous part of the automation is Continuous Deployment. Assume that your development branch is already tested and it is ready to deploy, Continuous Deployment allows you to upload your app directly through from your repository.

Most iOS developers think that deployment is one of the most painful parts of the development process. Because there are several steps to deploy your app to the App Store and if there is an error or problem you see an error window at “any” state of the process. It is really annoying because you have to sign your app, archive it and upload it to the iTunes Connect. You even might see an error message after half an hour passed if an error occurred. Therefore, you should automate it, so you won’t waste that much time again.


I hope this summary was helpful to understand the differences between continuous integration/delivery/deployment before learning about Bitrise.

Choosing an automation tool

There are plenty of automation tools such as Jenkins, Travis, Circle, Buddybuild and Bitrise. Each of them provides different solutions and experiences.

I have decided to use Bitrise instead of other tools. Because Bitrise:

  • Is specially built for mobile apps,
  • Has a free plan to use for CI without a time limit,
  • Has a good user experience,
  • Is well documented and partly open-sourced,
  • Has a responsive technical support service.

And I am still happy about deciding it 😊 There are also other reasons to love Bitrise and I want to show them in the tutorial part 🖖

Let’s dive in!

Creating a new app on Bitrise

Create a new repository

For this tutorial, I have created a public repo (or you can create in private, doesn’t matter) on GitHub. You can create your repository on Bitbucket or Gitlab, Bitrise supports them too.

Create a new Xcode project

Create an empty Xcode project. Add few simple unit tests into it. Push it to the repository.

Create a new app on Bitrise

If you don’t have a Bitrise account, you can create one from here. Adding an app to Bitrise is very easy.

Bitrise — app creation steps

After signing up, follow these steps:

  • Click “Add your first app” button.
  • Select owner and privacy of your app.
  • Connect the repository.
  • Choose a branch. I suggest you choose “master” because your base branch will be “master”. Probably you will keep the release versions on this branch.
  • After choosing the branch, validate your app. Before doing it, ensure that “Shared” box checked from your Xcode scheme settings.
  • Select project (or Workspace) path after validation. For this tutorial, I have chosen BitriseExample.xcodeproj. But if you are using Cocoapods or want to run on a workspace, you should select the path according to your workspace.
  • Choose a scheme name. BitriseExample for me, it should be your project name.
  • Select ipa export method. You can change it later so, choose “development” for now.
  • Choose the stack that you want to run your app. I suggest you select the stack same as Xcode and macOS version that you use already on your computer. Otherwise, you might see a failed build. This is an important step if you are running your build for the first time.
  • Let Bitrise registers a webhook for you.

That’s it! Easy, right?


Using Bitrise

Congratulations! You have successfully added your first app!

Here are the details about your app’s first build. I think the most important part on this screen is logs. It is very useful to identify the issues if you have a red build. We are sure that the app is running properly and all unit tests have passed!

Logs are pretty printed and I think it helps you to understand clearly.

Workflow Editor

Builds are running by following steps from your workflow.

There are 2 workflows by default:

  • Primary: This is the default workflow that allows you to clone your app from the repo, installs Cocoapods/Carthage if needed, runs your app and your unit/UI tests.
  • Deploy: Use this workflow if you want to deploy your app to the iTunes Connect (TestFlight or App Store).

These 2 workflows are enough for the default configurations at the beginning.

The picture above demonstrates how Workflow Editor looks like. You can edit or remove the steps or create a new one or reorder them. Adding or configuring a step is so easy and fun!

Click any “plus” button between the steps, you will see all the steps that you can add to your workflow. If you want to see only iOS/macOS tools, click the Apple icon from the top-right of the screen.

Workflow Editor is a very useful and powerful tool. And it is also open-source now.

Triggers

We can run the builds manually from the app detail screen. But how and when you will run your builds to automate your development process? There are triggers for that. In the example below, I have tried to explain how triggers work.

For instance, this trigger means:

When someone makes a Pull Request to the “master” branch (or which branch you want), trigger “primary” workflow.

By doing that, build is automatically running in the background before you start to review the code.

You can also set a new trigger if you want to run deploy workflow when someone tags a new version on any branch.

I have tried to explain the most important features on Bitrise. If you want to get more information about the other features, you can look at them from the editor.

How deployment works on Bitrise?

I won’t explain the deployment process in detail, but I want to give some key points to understand which steps you should provide on your “deploy” workflow.

Configuring “deploy” workflow

Well, you have a default “deploy” workflow. Let’s see how to update it for a successful deployment. I assume that you prefer to manage code signing automatically on your projects. So our deployment workflow has to contain “iOS Auto Provision” step for that.

  • Replace Certificate and profile installer step with iOS Auto Provision step. Certificate and profile installer step is used while making manually provisioning. Edit these fields on iOS Auto Provision step:
  1. Choose “Distribution type” app-store
  2. Set “The Developer Portal team id” if your developer account is linked more than one developer team. (Assume that you are using Application Loader to manage multiple developer team.)

For more detail: https://blog.bitrise.io/ios-auto-provision-step

  • Add Set Xcode Project Build Number step.

This is a crucial step that increases automatically your project’s build number for preventing conflicts while uploading ipa file to the iTunes Connect.

Type info.plist file path. “$BITRISE_SOURCE_DIR/BitriseExample/Info.plist” for me.

  • Add Cocoapods or Carthage installer step here if you use.
  • Place Xcode Test for iOS step.
  • Add Xcode Archive & Export for iOS step.
  • Add Deploy to iTunes Connect — Application Loader step to authenticate the iTunes Connect account. You have to enter the credentials as secrets for privacy. You will find the instructions there to do that.

The most important steps in the Workflow should look like this if you don’t use any dependency tool like Cocoapods or Carthage.

There is only one job to do before running your deploy workflow: Code Signing. Just follow the instructions on the “Code Signing” tab in your Workflow Editor, you will see how fun and easy it is.

Now, we are ready to deploy! Start to run a new build by clicking the “Start/Schedule a Build” button from the app detail.

Finally, you can get a badge for your README file to show your last build status by clicking here:


Concurrency & Pricing

Let’s talk about limitations and pricing plans. There are two plans for starters: hobby plan and developer plan.

Plans for personal account

You should consider these before deciding to use Bitrise:

  • Archiving and uploading ipa file to the iTunes Connect can take so much time to complete. If you are working on a big project and running on free (hobby) plan, you got 10 minutes for each build so it might not enough to complete.
  • You can run only 1 concurrent build, even you get a paid plan on the personal account. Sometimes you need to run more than one development branches or apps at the same time. I don’t think this is not so important if you are in a small team but if you have more than 5 people in your team, it would be better to look at organization account. There are options for increasing concurrencies on organization account but prices can be higher for sure.
Pricing for organization accounts

Thanks for reading!

Summary

Using any new tool takes time and effort to adapt it inside your workflow. You might face learning curve, questions from your team and some limitations. That’s normal.

I shared my experience with Bitrise, which fits my development structure and methodologies.

Please let me know your thoughts on improving workflow with CI/CD tools! I’m curious to learn from you. Here is a link to show the example app that I used in this tutorial:

If you don’t have a Bitrise account yet, you can use the referral link below to sign up. This will get me more free build time.


You can follow me on GitHub, Instagram, Twitter and LinkedIn to get more about me!