Over a million developers have joined DZone.

iOS Project: Integrating GitLab-CI, Fastlane, and HockeyApp

DZone's Guide to

iOS Project: Integrating GitLab-CI, Fastlane, and HockeyApp

Follow the key steps to create a base framework for CI/CD process.

· Integration Zone ·
Free Resource

WSO2 is the only open source vendor to be named a leader in The Forrester Wave™: API Management Solutions, Q4 2018 Report. Download the report now or try out our product for free.

There are many ways to implement CI/CD for iOS projects and choosing the right combination of technology is all depends on your project type, existing infrastructure and customer requirements. Here we’re using Fastlane – an open source technology for HockeyApp uploading, but Fastlane itself is mature and capable of handling all tedious tasks. Here is the easiest way to setup CI/CD by using GitLab-CI, Runner, Fastlane and HockeyApp for final app distribution.

Image title

Please follow the below key steps to create a base framework for CI/CD process:

  • Access to existing GitLab account/Create a new one

  • Setup GitLab-Runner in MacOSX build machine

  • Register GitLab-Runner with GitLab-CI

  • Install Fastlane in build/development machine

  • Enable GitLab-CI and Fastlane

  • Access to existing HockeyApp account / Create a new one

Before starting CI/CD implementation, make sure that GitLab account is ready and the code has been pushed to the repository from your development machine.

Setting up GitLab-Runner (MacOSX Machine)

$ sudo curl --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
$ gitlab-runner install

Register GitLab-Runner Instance With Your GitLab Account

$ sudo gitlab-runner register

Before executing the above command please note down or copy gitlab-ci token and gitlab-ci coordinator url from GitLab account -> Settings -> CICD

Image title

Image title

Once you are done with gitlab-runner registration process, start the GitLab-Runner by executing the following command:

$gitlab-runner start

Please make sure the runner status in GitLab account and note that "tag name" can be used to identify the specific GitLab-Runner instance and which can be added in the .gitlab-ci.yml file.

Image title

Installing Fastlane in Build/Development Machine

You need to install Fastlane on both the build and development machine in order to test and configure.

Execute the following command from your build and development machine "Terminal" to install Fastlane.

$sudo gem install fastlane -NV

After installing Fastlane in development machine, go to project root directory and initialize Fastlane dependencies for Swift.

$fastlane init swift

Once initialization is completed, open "Fastfile.swift" in Xcode and insert the following code for uploading iOS binary to HockeyApp:

func appBetaDistributionToHockeyApp() {
//Fastlane API to upload signed ipa to HockeyApp
hockey(apiToken:<<Token from HockeyApp account>>, ipa: <</ios-builds/beta/hellogitlab.ipa>>, notes:<<any notes here>)

Enable GitLab-CI

To enable GitLab-CI, create a new file called ".gitlab-ci.yml" and save it in your project root directory. Insert the following xcodebuild commands to the yml file to clean, buildarchive and export ipa from GitLab-Runner. It is mandatory to create an export options plist file with proper code signing identity and details.




- "xcodebuild -workspace HelloGitLab.xcworkspace -scheme HelloGitLab clean"

- xcodebuild -workspace HelloGitLab.xcworkspace -scheme HelloGitLab -configuration Debug CODE_SIGNING_REQUIRED=“NO” CODE_SIGNING_ALLOWED=“NO” -destination generic/platform=iOS archive -archivePath /ios-builds/archive/path/HelloGitLab.xcarchive

- "xcodebuild -exportArchive -archivePath /ios-builds/archive/path/HelloGitLab.xcarchive -exportPath /ios-builds/dev/ipa/path -exportOptionsPlist /ios-builds/dev/exportoptions-development.plist”

- "fastlane appBetaDistributionToHockeyApp"

stage: build


- ios


- build


Please validate your .gitlab-ci.yml file by using built-in GitLab validation tool or any yml lint tool available in online.

Export options plist

It is recommended to create multiple "export options" plist files for different targets like development, ad-hoc, enterprise etc with different code signing and provisioning profile details. Below is the sample one for development target.

<?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">
<key>bundle identifier</key>
<string>Provisioning profile name</string>
<string>Signing certificate name</string>

Once you complete all these steps, do a fresh commit and push the code into the GitLab repository and see the GitLab pipeline result.

Happy coding!

IAM is now more than a security project. It’s an enabler for an integration agile enterprise. If you’re currently evaluating an identity solution or exploring IAM, join this webinar.

ios ,xcode ,gitlab ,cicd ,swift ,gitlab runner

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}