Mastering iOS CI/CD: Crafting a Seamless Pipeline with Bitrise and Firebase App Distribution

Tharindu Ramesh Ketipearachchi
8 min readApr 7, 2024

--

In my previous articles, I delved into crafting CI/CD pipelines for both iOS and Android using Github Actions and VS AppCenter. While Github Actions provides unparalleled control over pipeline configuration, it demands significant time and scripting expertise, making it daunting for newcomers. However, alternative GUI-based services offer a swift solution. Bitrise stands out as one such tool, allowing users to construct comprehensive CI/CD pipelines effortlessly, entirely through its intuitive interface, without the need for manual scripting. Although it may lack the depth of customization offered by Github Actions, Bitrise excels in rapid pipeline deployment, often requiring only 20–30 minutes for setup. Moreover, it still offers the flexibility to fine-tune configurations through YAML scripts if necessary. Today, I will guide you through the swift creation of an iOS CI/CD pipeline, culminating in seamless distribution via Firebase App Distribution

  1. Configure build scheme on Xcode

Firstly, it’s crucial to configure our Xcode project properly. This involves setting up our build scheme with all the necessary configurations. By doing so, we streamline the process of building our project on a virtual machine (VM), eliminating the need to manually define these configurations within the pipeline. This ensures that everything is seamlessly configured within our project scheme, simplifying the CI/CD pipeline setup.

Then let’s configure the newly created scheme.

2. Add iOS Signing Certificates

Understanding iOS Signing Certificates can be challenging, especially for developers unfamiliar with iOS development practices. Here, we’ll break down the process into simple steps for easier comprehension.

  1. Create Apple ID for your app
  2. Create Apple Distribution profile
  3. Create Add-Hoc provisioning profile using Distribution Profile
  4. Configure provisioning profile on Xcode Scheme

3. Build CI/CD pipeline using Bitrise

  1. Create new app on Bitrise

2. Configure the project access

3. Connect your project repository

Bitrise supports many version controlling platforms

4. Then you should follow the next steps on Bitrise and complete your project. You need to grant authorization access, chose the default branch of the repo and other configurations.

4. Upload iOS code signing certificates & profiles to Bitrise

  1. Go to the App Settings > Files

2. Export Distribution Certificate

Go to the Apple Kecyain app > Certificates and export you distribution certificate as a p12 file.

3. Now click the Add file of the Bitrise settings and upload the downloaded p12 file as follows.

You will be asked to give a password when exporting the certificate.

Once you created a workflow as we mentioned in the next section, Go to the secret tab and add a new secret by entering that password as follows.

4. Download the Add-Hoc provisioning profile created from Apple developer account and upload it via Add file button

5. Create QA Release Pipeline

  1. Go to App > Workflows and click Create Workflow button

2. Give a name and create a new workflow

3. Click the plus(+) button of the left panel of the workflow Then the plugins search window will be appeared.

Then search Activate SSH and add the Activate SSH key module

You don’t need to edit anything here. Default configurations will works.

4. Add Git Clone Repository

Default configurations will works for this as well.

5. Add Bitrise Cache Pull

Default configurations will works for this as well.

6. Add Xcode Test for iOS to run Unit Tests

Here you need to give your scheme name (QA)

And your Test Plan name (QATestPlan)

7. Add certificate and profile installer

This is the most critical part of our CI/CD pipeline and this plugin will be taking care of all of our iOS code signings. So you need to change following variables correctly on this plugin.

(I) Change the value of Certificate URL and add the exact URL which was auto generated on section 4 (2. Export Distribution Certificate)

(II) Change the value of Provisioning profile URL and give the exact value which was generated on section 4 (4. Download the Add-Hoc provisioning profile created from Apple developer account and upload it via Add file button)

(III) Change the value of Certificate Passphrase and give the secret variable name which we have created on section 4 (2. Export Distribution Certificate)

If you have any doubts about these certificate related URL names, You’ll be able to copy those from Code Signing & Files tab

8. Add Xcode Archive & Export for iOS

Add schema as QA and Distribution method as ad-hoc

9. Add Bitrise Cache Pull Again

10. Add Deploy to BitriseIO

6. Distribute the app using firebase

  1. Add a new firebase project

2. Add app to your project

Select iOS as platform and give the bundle ID of your iOS project and the correct app name

Since we aren’t going to use push notifications or any other firebase services on our app, we don’t need to add firebase SDK to our iOS project and don’t need to do any of the code changes of our iOS project. We are just going to use firebase app distribution only.

3. Go to App Distribution > Testers & Groups and Add a testing group,

Then add your QA team members and others need to access the app by using their emails.

4. Go to your workflow and add Firebase App Distribution

5. Get firebase token

Install the Firebase CLI if you haven’t got it on your machine already.

// auto install script for Mac OS or Linux users> curl -sL firebase.tools | bash

To Use the CLI with CI systems login into the Firebase and get a token.

> firebase login:ci

Once authentication process is completed, your token is printed out on the console. (Example token: 1/a1gqPSI3ryNcsDiZnCaHnY-hg9u9nJeosz3iNPe-S-RLdmqdypiJMOjoeOhOGsWK)

Now, open the Secrets tab of your Workflow Editor and add the token as a new Secret Environment Variable.

6. Change the Firebase Token variable of your firebase Bitrise pluging with above Environment Variable

7. Get the firebase App ID from Your project settings

Copy this value and paste it on Firebase App ID parameter section

8. Add your testing group name as Test Groups variable.

Now we are done with our pipeline.

7. Conclusion

Now, you can observe that constructing an iOS CI/CD pipeline is remarkably straightforward and significantly less time-consuming compared to Github Actions. Once you’ve completed the pipeline setup, you’ll have the capability to view and edit the relevant YAML script directly from Bitrise.

--

--

Tharindu Ramesh Ketipearachchi

Technical Lead (Swift, Objective C, Flutter, react-native) | iOS Developer | Mobile Development Lecturer |MSc in CS, BSc in CS (Col)