CI for Swift
Build, lint, and test a Swift project using SwiftLint and XCTest.
Use template →1env:
2 SWIFT_CACHE_PATH: .cache
3
4steps:
5 - label: ":swift: Build"
6 key: "build"
7 command: "swift build --cache-path $SWIFT_CACHE_PATH"
8 plugins:
9 - docker#v5.9.0:
10 image: "swift:5.10"
11 - artifacts#v1.9.3:
12 upload: "$SWIFT_CACHE_PATH"
13 compressed: cache.tgz
14
15 - label: ":swift: Lint"
16 command: "swiftlint"
17 plugins:
18 - docker#v5.9.0:
19 image: "ghcr.io/realm/swiftlint:latest"
20 platform: "linux/amd64"
21
22 - label: ":swift: Test"
23 command: "swift test --cache-path $SWIFT_CACHE_PATH"
24 depends_on: ["build"]
25 plugins:
26 - docker#v5.9.0:
27 image: "swift:5.10"
28 - artifacts#v1.9.3:
29 download: "$SWIFT_CACHE_PATH"
30 compressed: cache.tgz
CI for Swift
This template gives you a continuous integration (CI) pipeline that builds, lints, and tests a Swift project.
At a glance:
- For Swift projects
- Requires Docker
- Uses the Swift Package Manager
- Lints code with SwiftLint
- Tests code using XCTest
How it works
This template:
- Builds your Swift project, caching dependencies for subsequent steps.
- Lints the code with SwiftLint.
- Runs tests with XCTest.
The runtime environment uses the official Swift Docker image with the latest version.
Next steps
After you select Use template, you’ll:
- Connect the Git repository with your Swift project.
- Modify the commands if necessary.
- Configure the compute—run locally, on-premises, or in the cloud.
- Run the pipeline.
You can then play around with the pipeline settings. For example, run the pipeline locally while you iterate on the definition or set a schedule to trigger a nightly build.
If you need help, please check our documentation, raise an issue , or reach out to support.