On a CI machine I'm using xcodebuild with automatic package resolution disabled, like this:
/Applications/Xcode-13.2.1.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies -scheme "SJ Debug" -project SJ.xcodeproj -derivedDataPath "~/Library/Developer/Xcode/DerivedData" -scmProvider system -disableAutomaticPackageResolution
This works, however, whenever I update a package and the Resolved.packages file is changed I get errors of the following kind:
xcodebuild: error: Could not resolve package dependencies: Couldn’t check out revision ‘8354a50fe01a7e54e196d3b5493b5ab53dd5866a’: fatal: reference is not a tree: 8354a50fe01a7e54e196d3b5493b5ab53dd5866a an out-of-date resolved file was detected at /repo.git/SJ.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved, which is not allowed when automatic dependency resolution is disabled; please make sure to update the file to reflect the changes in dependencies fatalError
The real error is that git checkout fails, the rest of the error message is not correct. The question then is why does it fail?
If I wipe the package cache things will work again.
Also, if I add the flag -clonedSourcePackagesDirPath SourcePackages then package resolution also works (at least if SourcePackages is an empty directory).
On the machine xcodebuild is invoked by fastlane which invokes xcodebuild which uses swift package manager (some built in version of it?). So it is hard to know where to actually report this error but I feel like it must be affecting lots of people.
Does anyone here have any insight into this?
The actual error output looks like it is coming from here: swift-package-manager/Workspace.swift at 7a75eb8cfdba5a8c73914db3ad08e83b8051e68d · apple/swift-package-manager · GitHub
I believe the real reason behind the "not a tree" error may be that something is wrong with the git invocation perform by swift package manager (wrong working dir or something like that).