I remember this "working" in Xcode 15.4. The code paths were executed at least, but some SPM bugs prevented packages from being resolved correctly. Xcode 16.2 doesn't behave the same way anymore. It ignores registries.json but even if you specify everything via command line, it doesn't work.
I can get it to produce errors like the below:
product 'Logging' required by package 'cocoalumberjack' target 'CocoaLumberjackSwiftLogBackend' not found in package 'swift-log'. Did you mean '.product(name: "Logging", package: "apple.swift-log")'?
This indicates it's hitting some related code path, but the registry related cache folders are never created, so it's hard to tell what it's actually doing.
Part of the issue may be how the CLI parameters are handled internally. Since you can configure many settings via user defaults or env vars as well, Xcode has some mechanism for tying these different methods together. If you use a wrong value for -packageDependencySCMToRegistryTransformation
, you get this error.
Could not initialize package support: Invalid source control transform ‘blah’ provided for user default ‘IDEPackageDependencySCMToRegistryTransformation’ (expected `none`, `use-registry-identity-for-scm`, or `replace-scm-with-registry`).
Those are the SPM CLI parameters, which xcodebuild does not accept. It wants you to use useRegistryIdentity
and useRegistryIdentityAndSources
instead. It looks like it was done in a hurry.
As an aside, with the hint to the user defaults key name above, you can actually get Xcode itself to hit the same code paths.
defaults write com.apple.dt.Xcode IDEPackageDependencySCMToRegistryTransformation useRegistryIdentityAndSources
But as far as I can tell, it doesn't work either.