Managing dependencies with SPM
On Bitrise, every Xcode Step can handle Swift package dependencies without any extra configuration. You can install and cache SPM packages easily.
Swift packages are reusable components of Swift, Objective-C, Objective-C++, C, or C++ code that developers can use in their projects. Xcode uses the built-in Swift Package Manager (SPM) to support creating and publishing Swift packages and managing package dependencies.
On Bitrise, every Xcode Step can handle Swift package dependencies without any extra configuration. For example, if you wish to build an iOS app to deploy it to the App Store, the Xcode Archive & Export for iOS Step will handle installing Swift dependencies to your app.
Installing Swift packages
You can easily install Swift packages for your iOS apps during a Bitrise build:
-
Make sure you have correctly configured your Swift packages in Xcode.
-
Add one of our official Xcode Steps to your Workflow. The available Steps are:
-
Xcode Archive & Export for iOS
-
Xcode Test for iOS
-
Xcode Build for testing
-
Xcode Build for Simulator
Any of these Steps can handle the Swift package dependencies.
-
Caching Swift packages
There are two ways to cache Swift packages in a build, depending on whether you use key-based caching or branch-based caching.
Key-based caching
Key-based caching is only available for credit-based accounts!
Key-based caching
Branch-based caching
With key-based caching, you only need the Restore SPM cache and the Save SPM cache Steps to cache your Swift packages. These Steps require no configuration as they automatically set up the cache keys needed for your dependencies.
Setting specific cache paths
You don't have to use the default cache paths that the dedicated key-based caching Steps use. If you need to set a specific cache path, you can do so by configuring the Save Cache and the Restore Cache Steps: Using key-based caching in your builds.
-
Add the Restore SPM cache Step to your Workflow
It should come before any Step that handles SPM packages in any way, such as Xcode Archive & Export for iOS.
-
Add the Save SPM cache Step to the end of your Workflow.
Branch-based caching relies on the built-in feature of all our Xcode Steps to collect Swift package cache content. The Xcode Archive & Export for iOS, Xcode Test for iOS, Xcode Build for testing for iOS, and the Xcode Build for Simulator Steps can all collect Swift package cache content.
Setting specific cache paths
You don't have to use the default cache paths that the built-in caching options use. If you need to set a specific cache path, you can do so in the Bitrise.io Cache:Pull and the Bitrise.io Cache:Push Steps: Including files and folders in the build cache.
-
Add the Bitrise.io Cache:Pull Step to your Workflow.
It should come before any Step that handles SPM packages in any way, such as Xcode Archive & Export for iOS. The Step requires no extra configuration if you use our Xcode Steps.
-
Enable Swift package caching in the Xcode Step(s) you use in your build: in the Caching input group, set the Enable collecting cache content input to .
-
Add the Bitrise.io Cache:Push Step to the end of your Workflow.
The Step requires no extra configuration if you use our Xcode Steps.