doc/ci/mobile_devops/mobile_devops_tutorial_ios.md
In this tutorial, you'll create a pipeline by using GitLab CI/CD that builds your iOS mobile app, signs it with your credentials, and distributes it to app stores.
To set up mobile DevOps:
Before you start this tutorial, make sure you have:
fastlane installed locallyUse GitLab-hosted runners, or set up self-managed runners for complete control over the build environment.
Create a .gitlab-ci.yml file in your repository root.
Add a supported macOS images to run a job on a macOS GitLab hosted runners (beta):
test:
image: macos-14-xcode-15
stage: test
script:
- fastlane test
tags:
- saas-macos-medium-m1
To set up code signing for iOS, upload signed certificates to GitLab by using fastlane:
Initialize fastlane:
fastlane init
Generate a Matchfile with the configuration:
fastlane match init
Generate certificates and profiles in the Apple Developer portal and upload those files to GitLab:
PRIVATE_TOKEN=YOUR-TOKEN bundle exec fastlane match development
Optional. If you have already created signing certificates and provisioning profiles for your project, use fastlane match import to load your existing files into GitLab:
PRIVATE_TOKEN=YOUR-TOKEN bundle exec fastlane match import
You are prompted to input the path to your files. After you provide those details, your files are uploaded and visible in your project's CI/CD settings.
If prompted for the git_url during the import, it is safe to leave it blank and press <kbd>enter</kbd>.
The following are sample fastlane/Fastfile and .gitlab-ci.yml files with this configuration:
fastlane/Fastfile:
default_platform(:ios)
platform :ios do
desc "Build and sign the application for development"
lane :build do
setup_ci
match(type: 'development', readonly: is_ci)
build_app(
project: "ios demo.xcodeproj",
scheme: "ios demo",
configuration: "Debug",
export_method: "development"
)
end
end
.gitlab-ci.yml:
build_ios:
image: macos-12-xcode-14
stage: build
script:
- fastlane build
tags:
- saas-macos-medium-m1
Signed builds can be uploaded to the Apple App Store by using the Mobile DevOps Distribution integrations.
Prerequisites:
To create an iOS distribution with the Apple Store integration and fastlane:
The following is a sample fastlane/Fastfile:
default_platform(:ios)
platform :ios do
desc "Build and sign the application for distribution, upload to TestFlight"
lane :beta do
setup_ci
match(type: 'appstore', readonly: is_ci)
app_store_connect_api_key
increment_build_number(
build_number: latest_testflight_build_number(initial_build_number: 1) + 1,
xcodeproj: "ios demo.xcodeproj"
)
build_app(
project: "ios demo.xcodeproj",
scheme: "ios demo",
configuration: "Release",
export_method: "app-store"
)
upload_to_testflight
end
end
The following is a sample .gitlab-ci.yml:
beta_ios:
image: macos-12-xcode-14
stage: beta
script:
- fastlane beta
Congratulations! Your app is now set up for automated building, signing, and distribution. Try creating a merge request to trigger your first pipeline.
Sample Mobile DevOps projects with pipelines configured to build, sign, and release mobile apps are available for:
View all projects in the Mobile DevOps Demo Projects group.