BLOGS

iOS CI/CD Integration using Gitlab CI

Category
ENTERPRISE MOBILITY
Author
VIGNESWARAN
Date
07/22/2019

This post helps you to create CI/CD pipeline for an iOS application using Gitlab CI and fastlane tool.

Share on facebook
Share on twitter
Share on whatsapp
Share on linkedin
Share on facebook
Share on twitter
Share on whatsapp
Share on linkedin
We have two parts in this process, while setting up the CI/CD pipeline:

  1. Configuring the gitlab runner (Note: You need a macOS machine for building iOS apps. So, you need to configure this runner in a macOS machine for this CI/CD process.) and creating a .gitlab.yml file in the repository and define the workflow with required scripts.

  2. Defining fastlane configuration using Fastfile for building,signing and uploading the application to testflight/releasing the build to App Store.
Gitlab Runner Setup Run the following commands for installing Gitlab runner in your machine.

sudo curl --output /usr/local/bin/gitlab-runner https://gitlab-runner
-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
cd ~
gitlab-runner install
gitlab-runner start

.gitlab.yml:

stages:
  - build

variables:
  LC_ALL: "en_US.UTF-8"
  LANG: "en_US.UTF-8"
  GIT_STRATEGY: clone

build:
  stage: build
  script:
- bundle install
- bundle exec fastlane beta
artifacts:
  paths:
- ./MyApp.ipa

 

Fastlane Integration:

Fastlane primarily here serves the following purposes, namely:

  1. Run UI tests
  2. Run unit tests
  3. Build ipa file and Upload to testflight
For integrating fastlane into your project, run the following commands in the below.  

xcode-select --install
sudo gem install
fastlane -NV
# Alternatively using Homebrew
# brew cask install fastlane
fastlane init
The fastfile is used for configuring the steps in a particular lane responsible for beta deployment of the application.

default_platform(:ios)
platform :ios do
 desc "Build the application"
 lane :beta do
   match(type:”appstore”,readonly:true)
   gym
   upload_to_testflight
  end
end
​​
There are some special environment variables behind the scenes here that are making this work.
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD and FASTLANE_SESSION

In order to authenticate against the App Store for the TestFlight upload, fastlane must be able to authenticate. In order to do this, you need to create an app-specific password to be used by CI. You can read more about this process in this documentation.

If you’re using two-factor authentication, you’ll also need to generate the FASTLANE_SESSION variable – instructions are in the same place.

UAE

P.O. Box: 128274
Dubai United Arab Emirates

[email protected]
+971 4 2500 966

INDIA

Kakkanad P.O.,
Kochi 682030, Kerala

[email protected]
+91 484 242 1316

Join our newsletter

© 2019, BLUECAST All Rights Reserved.