|
| 1 | +# Continuous Integration Workflows |
| 2 | + |
| 3 | +Build Swift packages with an existing continuous integration setup and prepare apps that consume package dependencies within an existing CI pipeline. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +*Continuous integration* (*CI*) is the process of automating and streamlining the building, analyzing, testing, archiving, and publishing of your apps to ensure that they're always in a releasable state. |
| 8 | +Most projects that contain or depend on Swift packages don't require additional configuration. |
| 9 | + |
| 10 | +## Use the Expected Version of a Package Dependency |
| 11 | + |
| 12 | +To ensure a CI workflow’s reliability, verify it uses the appropriate version of package dependencies. |
| 13 | +SwiftPM records the result of dependency resolution in the file `Package.resolved`, at the top-level of the package. |
| 14 | +When available, it's used when performing dependency resolution. |
| 15 | + |
| 16 | +Run <doc:PackageUpdate> to update dependencies to the latest eligible versions and update `Package.resolved`. |
| 17 | +For more information on resolving and updating dependencies, see <doc:ResolvingPackageVersions>. |
| 18 | + |
| 19 | + |
| 20 | +## Provide Credentials |
| 21 | + |
| 22 | +To resolve package dependencies that require authentication, such as private packages, provide credentials to your CI setup. |
| 23 | +Package manager honors the machine's SSH configuration - there's no additional setup required. |
| 24 | +For private package, use the SSH-based Git URLs and configure SSH credentials. |
| 25 | +You may also need to set up a `known_hosts` file in the `~/.ssh` directory of the user that runs your CI tasks. |
| 26 | + |
| 27 | +CI services like [Jenkins](https://www.jenkins.io/doc/book/using/using-credentials), [Github Action](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow), [TravisCI](https://docs.travis-ci.com/user/private-dependencies), and [CircleCI](https://circleci.com/docs/2.0/gh-bb-integration/#security) provide ways to set up SSH keys or other techniques to access private repositories. |
| 28 | +Since Package manager uses git to clone the repositories there's no additional setup required; Package manager honors the machine's SSH and Git configuration. |
| 29 | + |
| 30 | +## Using xcodebuild |
| 31 | + |
| 32 | +When building on macOS based CI hosts you can use the command-line tool `xcodebuild`. |
| 33 | +`xcodebuild` uses Xcode's built-in Git tooling to connect to repositories. |
| 34 | + |
| 35 | +In many cases, you don't need to make changes to how xcodebuild connects to them. |
| 36 | +However, some use cases require you use the git configuration — for example URL remapping, the use of proxies, or advanced SSH configurations. |
| 37 | +To have xcodebuild use your Mac's Git installation and configuration instead of Xcode's built-in Git tooling, pass `-scmProvider system` to the xcodebuild command. |
| 38 | + |
| 39 | +For more information on using xcodebuild in continuous integration workflows, visit [Building Swift packages or apps that use them in continuous integration workflows](https://developer.apple.com/documentation/swift_packages/building_swift_packages_or_apps_that_use_them_in_continuous_integration_workflows). |
0 commit comments