-
Download Gitlab Runner on MacOS
$ 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
-
Register runner for your project and get your token from GitLab project CI/CD settings
gitlab-runner register
-
Prepare
Gemfile
source "https://rubygems.org" gem "fastlane" gem "cocoapods" gem "xcov"
-
Install
Fastlane
and initialize the projectbundle install —-path vendor/bundle fastlane init
-
Cocoapod initialization and setup
SwiftLint
in your project according to https://github.com/realm/SwiftLintpod init pod 'SwiftLint'
-
Add lint lane and test lane to
Fastfile
desc "Does a static analysis of the project. Configure the options in .swiftlint.yml" lane :lint do swiftlint( mode: :lint, executable: "Pods/SwiftLint/swiftlint", reporter: "html", output_file: "fastlane/swiftlint-results.html", config_file: '.swiftlint.yml', ignore_exit_status: true ) end desc "Test an measure code coverage" lane :test do run_tests(devices: ["iPhone 11"]) xcov( workspace: "Yourproject.xcworkspace", scheme: "yourschema", output_directory: "fastlane/xcov_output" ) end
- prepare
.gitlab-ci.yml
file
stages:
- lint
- unit_tests
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
before_script:
- bundle install --path vendor/bundle
- bundle exec pod install
lint:
dependencies: []
stage: lint
script:
- fastlane lint
tags:
- ios
unit_tests:
dependencies: []
stage: unit_tests
script:
- fastlane test
tags:
- ios
-
Start Runner
gitlab-runner start gitlab-runner run
-
Commit
.gitlab-ci.yml
changes and push it to Gitlab
https://medium.com/@phanquanghoang/using-gitlab-ci-cd-fastlane-for-ios-project-part-1-5e7db82a3566
https://medium.com/@phanquanghoang/using-gitlab-ci-cd-fastlane-for-ios-project-part-3-f710b618da4a