CI for iOS with Bitbucket Pipelines

David Ups
3 min readJan 31, 2023

--

How to add continues integration for iOS and donโ€™t dead trying ๐Ÿš€

Requirements

Runner machine, run

You can have a local project Runner or a workspace runner, I recommend the workspace became the runner will only make the connection between the bitbucket and the machine.

Installing the runner ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ

  • Go to workspace settings > workspace runners
  • Click on Add Runner
  • Select MacOS on system and architecture
  • Download the runner zip
curl https://product-downloads.atlassian.com/software/bitbucket/pipelines/atlassian-bitbucket-pipelines-runner-1.397.tar.gz --output atlassian-bitbucket-pipelines-runner.tar.gz
  • Extract the file
mkdir atlassian-bitbucket-pipelines-runner && tar -xzvf atlassian-bitbucket-pipelines-runner.tar.gz -C atlassian-bitbucket-pipelines-runner
  • Launch the runner and donโ€™t close the terminal.
cd atlassian-bitbucket-pipelines-runner/bin
./start.sh //command indicated on the documentation 

If everything goes well you will see

Apple things ๐Ÿง‘๐Ÿผโ€๐Ÿ’ป

Save the Team ID, you can obtain it on Apple develop > Account > Membership details.

Then take the provision profile of your app and add it to the machine that will be used for CI

Firebase Distribution ๐Ÿ”ฅ

  • First of all enable the firebase app distribution.
  • Execute the firebase login:ci and save the token, if you donโ€™t have install the Firebase CLI, install it.
  • Save the application ID

Prepare the project ๐Ÿ—

Create a folder ci that it will contains

  • groups.txt โ†’ Here write the Firebase distributions groups.
  • releasenotes.txt โ†’ Here write the app release notes.
  • testers.txt โ†’ Here write the testers mails.
  • profile โ†’ Here we will create the export.plist

Export.plist

This file we will use to generate the IPA.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>enterprise</string>
<key>teamID</key>
<string>Insert teamID</string>
<key>uploadBitcode</key>
<false/>
<key>compileBitcode</key>
<true/>
<key>uploadSymbols</key>
<true/>
<key>signingStyle</key>
<string>manual</string>
<key>signingCertificate</key>
<string>Apple Distribution</string>
<key>provisioningProfiles</key>
<dict>
<key>Insert the package name like com.example.example</key>
<string>Insert the provision profile name</string>
</dict>
</dict>
</plist>

Every app have her own export.plist

Bitbucket Pipeline

This is the last step of our beautiful path, so letโ€™s go!

Edit your bitbucket-pipelines.yml to something like:

pipelines:
custom:
deploy_firebase_version:
- step:
runs-on:
- self.hosted
- macos
script:
- pod install
- xcodebuild -workspace YOUR-APP-WORKSPACE.xcworkspace -scheme YOUR-SCHEME -archivePath build/version/app.xcarchive archive
- xcodebuild -exportArchive -archivePath build/version/app.xcarchive -exportPath build/version -exportOptionsPlist ci/profile/export.plist
- firebase appdistribution:distribute IPA-PATH --app FIREBASE-APPLICATION-ID --release-notes-file ci/releasenote.txt --groups-file ci/groups.txt --testers-file ci/testers.txt --token FIREBASE-TOKEN

Launch your pipeline

Project > Pipelines > Run Pipeline

Take a coffee and wait for the result! โœ…

--

--