iOS Continuous Integration and Delivery using Bitrise and Fastlane — Part 1

Abedalkareem Omreyh
5 min readJun 22, 2019

--

This is a part of a series about iOS continuous integration and delivery.

Part 2: Match, increment version number, increment build number and add badge actions.

Part 3: gym, Pilot and Slack

Part 4: Bitrise!

Part 5: Workflows and Triggers

In this series, we are going to go through all the steps to automate our tests, beta releases and even the app store releases, but before we start I need to thank Moski Doski for helping and guiding me through this journey.

What we will achieve at the end?

What we will achieve at the end

At the end of this series, after pushing your code to the Develop branch, a unit tests will run and after that, it will send a success or failure message to slack. In case of pushing your code to the Master branch, Bitrise will make a build for you, upload it to iTunes connect, and then publish it to your testers.

Let’s start!

In this part we will understand four main things before we start, What is continuous integration, continuous Delivery, Fastlane and Bitrise.

1-Continuous integration: In continuous integration, the developers merge their changes back to the main branch as often as possible. The developer’s changes are validated by creating a build and running automated tests. By doing this, you avoid the integration hell that usually happens when people wait for release day to merge their changes into the release branch.

2-Continuous delivery: Continuous delivery is an extension of continuous integration to make sure that you can release new changes to your customers quickly in a sustainable way. This means that on top of having automated the testing, you also have automated your release process and you can deploy your application at any point of time by pushing your code to a specific branch.

3-Bitrise: Bitrise is a Continuous Integration and Delivery (CI/CD) Platform as a Service (PaaS) (you will ask your self what is PaaS, don’t worry as we will talk about this in a moment), so Bitrise is a collection of tools and services to help you with the development and automation of your software projects.

Now what is a Platform as a Service (PaaS), PaaS is a category of cloud computing services that provides a platform allowing customers to develop, run, and manage applications without the complexity of building and maintaining the infrastructure.

What you manage in PaaS and what vendor manage.

4-Fastlane: Fastlane is an open-source platform aimed at simplifying Android and iOS deployment. Fastlane lets you automate every aspect of your development and release workflow. like generating screenshots, dealing with provisioning profiles, and releasing your application.

The App

let’s have a look at the app we will use through this series, it’s a very simple app, the app has one label and two buttons the first button sums the number 9 and ten, and the second button subtract one from this number.

Screenshot from the app

We have three main classes, ViewController, MyMath and MyAppTests, the MyMath class is just a small helper to help us do the calculations, while the MyAppTest class has tests for MyMath class.

You can get the starter project from here:

Fastlane

The first step we need to install Fastlane you can install Fastlane by running the following command:

sudo gem install fastlane -NV

next, go to the project directory and run the following command to add Fastlane to our project:

fastlane init

It will show to you a list of choices, choose “Manual setup” as we will manually set up our project to automate our tasks, press enter and wait until it finishes.

Now if we go to our project we will find a new folder, Fastlane folder, open it and you will find the Fastlane file, open this file with any editor of your choice.

Fastlane file

In this file we will write our lanes if you are asking what is a lane, it’s a group of actions to automate a task like pushing a new build to TestFlight.

First, let’s add a description for our lane, you can add whatever you want for the description, I’ll write what we will do in this lane, “Push new build to the TestFlight”, We will name the lane to the beta as it will push a beta build to TestFlight.

Now let’s run the lane that we just created, Go to the terminal and write:

fastlane beta

It will show us a success message but it didn’t do anything as we didn’t write any actions, don’t worry as that’s what we are going to do in our next part of this series! adding actions!

That’s it for this part. If you faced any problem you can add a comment below or send me a message on Twitter or facebook.

Part 2: Match, increment version number, increment build number and add badge actions.

--

--