In this comprehensive guide, you'll learn how to leverage GitLab Mobile DevOps to streamline your Swift app development process. By setting up a pipeline with GitLab CI/CD, you can automate the building, signing, and distribution of your iOS mobile app.
Before You Begin
Before diving into this tutorial, make sure you have:
- A GitLab account with access to CI/CD pipelines
- Your mobile app code in a GitLab repository
- An Apple Developer account
- Fastlane installed locally
Setting Up Your Build Environment
To start, create a .gitlab-ci.yml file in your repository root. This file will serve as the configuration for your pipeline.
For complete control over the build environment, you can use self-managed runners or opt for GitLab-hosted runners with supported macOS images. For example, you can run a job on a macOS GitLab-hosted runner (beta) using the following code:
`
test: image: macos-14-xcode-15
stage: test
script:
- fastlane test
tags:
- saas-macos-medium-m1
`
Configuring Code Signing with Fastlane
To set up code signing for your iOS app, you'll need to generate signed certificates and upload them to GitLab using fastlane. Start by initializing fastlane:
`
fastlane init
`
Next, generate a Matchfile with the configuration:
`
fastlane match init
`
Then, generate certificates and profiles in the Apple Developer portal and upload those files to GitLab:
`
PRIVATE_TOKEN=YOUR-TOKEN bundle exec fastlane match development
`
Alternatively, if you've already created signing certificates and provisioning profiles for your project, use fastlane match import to load your existing files into GitLab. You'll be prompted to input the path to your files.
Setting Up App Distribution with Apple Store Integration and Fastlane
Once you have signed builds, you can upload them to the Apple App Store using the Mobile DevOps Distribution integrations. To do this, you'll need:
- An Apple ID enrolled in the Apple Developer Program
- A new private key for your project in the Apple App Store Connect portal
Generate an API Key for App Store Connect API and enable the integration. Provide the Apple App Store Connect configuration information:
`
Issuer ID: The Apple App Store Connect issuer ID.
Key ID: The key ID of the generated private key.
Private key: The generated private key. You can download this key only once.
Protected branches and tags only: Enable to set variables on protected branches and tags only.
`
Sample Projects
Want to see swift app development in action? View sample projects with pipelines configured to build, sign, and release mobile apps for:
- Android
- Flutter
- iOS
Explore the Mobile DevOps Demo Projects group to find inspiration for your own project.