Hi,
Our project started using SPM for 3rd party dependencies instead of xcframework but we started seeing huge increases in build times. I was wondering what is the right approach in caching the builds of all SPM dependencies so that we don't recompile them on subsequent builds.
Is this possible or should we stick with xcframework instead ?
There are a few build parameters that might be of interest to you:
-resolvePackageDependencies resolves any Swift package dependencies referenced by the project or workspace
-disableAutomaticPackageResolution prevents packages from automatically being resolved to versions other than those recorded in the `Package.resolved` file
-onlyUsePackageVersionsFromResolvedFile prevents packages from automatically being resolved to versions other than those recorded in the `Package.resolved` file
-disablePackageRepositoryCache disable use of a local cache of remote package repositories
-packageCachePath path of caches used for package support
You can try creating a separate job that uses -packageCachePath
just to cache the dependencies, and on the actual build configuration to -onlyUsePacakgeVersionsFromResolvedFile
in tandem with previously used -packageCachePath
. I haven't tried these myself but it looks like something you might find useful.
Thanks for your reply. It gave me a few more leads to try and fix my issue.
I'm really curious about the packageCachePath
parameter as I'm not able to make it work or I'm probably using it in a wrong way. Can you point me to a valid xcodebuild command that uses it ?
Sadly I can't find any examples. My answer was written purely on things I found in xcodebuild's manual page :( although the flag implies usage of global cache. So the cached Swift PM repositories should be somewhere in ~/Library/Cache/com.apple.swiftpm
or something similar.