DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Implementing Infrastructure as Code (IaC) for Data Center Management
  • On SBOMs, BitBucket, and OWASP Dependency Track
  • Scaling CI/CD: Standardizing Pipelines in Large-Scale Organizations
  • Enhancing Security in Kubernetes: A Comparative Analysis of Cosign and Connaisseur

Trending

  • Blue Skies Ahead: An AI Case Study on LLM Use for a Graph Theory Related Application
  • Medallion Architecture: Why You Need It and How To Implement It With ClickHouse
  • Mastering Advanced Traffic Management in Multi-Cloud Kubernetes: Scaling With Multiple Istio Ingress Gateways
  • DGS GraphQL and Spring Boot
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. iOS Project (CI/CD): Integrating GitLab-CI, Fastlane, HockeyApp, and AppCenter

iOS Project (CI/CD): Integrating GitLab-CI, Fastlane, HockeyApp, and AppCenter

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

By 
Manesh Das user avatar
Manesh Das
·
Updated Mar. 12, 19 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
59.0K Views

Join the DZone community and get the full member experience.

Join For Free

There are many ways to implement CI/CD for iOS projects, and choosing the right combination of technology all depends on your project type, existing infrastructure, and customer requirements. Here, we’re using Fastlane — an open-source technology for HockeyApp/AppCenter 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 AppCenter/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 AppCenter/HockeyApp account or 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 write 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 the 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, 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 your development machine, go to project root directory and initialize Fastlane dependencies for Swift. The Swift version of Fastlane is in Beta stage, and this will not support Fastlane-Plugins. If you choose AppCenter or any other distribution platform that requires additional Fastlane-plugins, then you can avoid the "swift" parameter from the below command.

$fastlane init swift

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

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>)
}
func appBetaDistributionToAppCenter() {
//Fastlane API to upload signed ipa to AppCenter
 appcenter_upload(
    api_token: "<appcenter token>",
    owner_name: "<your appcenter account name>",
    app_name: "<your app name>",
    ipa: "<path to iOS build>"
  )
}

Install Fastlane — AppCenter Plugin

To upload application binary to AppCenter, you need to install the AppCenter-plugin for Fastlane.

fastlane add_plugin appcenter

https://github.com/Microsoft/fastlane-plugin-appcenter

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, build, archive, and export ipa from GitLab-Runner. It is mandatory to create an export options plist file with proper code signing identity and details.

-----------------

build_project:

script:

- "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

tags:

- ios

stages:

-----------------

Please validate your .gitlab-ci.yml file by using built-in GitLab validation tool or any yml lint tool available 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">
<dict>
<key>compileBitcode</key>
<false/>
<key>method</key>
<string>development</string>
<key>provisioningProfiles</key>
<dict>
<key>bundle identifier</key>
<string>Provisioning profile name</string>
</dict>
<key>signingCertificate</key>
<string>Signing certificate name</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<false/>
<key>teamID</key>
<string>teamID</string>
<key>thinning</key>
<string>&lt;none&gt;</string>
</dict>
</plist>

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!

Continuous Integration/Deployment

Opinions expressed by DZone contributors are their own.

Related

  • Implementing Infrastructure as Code (IaC) for Data Center Management
  • On SBOMs, BitBucket, and OWASP Dependency Track
  • Scaling CI/CD: Standardizing Pipelines in Large-Scale Organizations
  • Enhancing Security in Kubernetes: A Comparative Analysis of Cosign and Connaisseur

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: