xcodebuild not resolving local swift package dependencies

My project has swift package dependencies hosted on GitHub, others that are local (on disk).

Building the project from Xcode works fine, but building from the command line, e.g xcodebuild -project "../MyProj.xcodeproj" -scheme "MyScheme" fails because the local swift packages fail resolve (while the GitHub-hosted packages are resolved with no issues). In other words, I get a flurry of errors like these:
error: Missing package product 'MyLocalSwiftPackage'

Running xcodebuild with -resolvePackageDependencies successfully resolves all the GitHub-hosted Swift Packages, but ignores the local ones.


Does xcodebuild need explicit instructions for locating local Swift Package dependencies?
Answered by tifroz in 650245022
I figured it out - I had moved the project into the same workspace which contains the local Swift Package dependencies: building the project was my mistake, I should have been building the workspace.

In other words xcodebuild -workspace "../MyWorkSpace.xcworkspace" -scheme "MyScheme instead of xcodebuild -project "../MyProj.xcodeproj" -scheme "MyScheme"
Accepted Answer
I figured it out - I had moved the project into the same workspace which contains the local Swift Package dependencies: building the project was my mistake, I should have been building the workspace.

In other words xcodebuild -workspace "../MyWorkSpace.xcworkspace" -scheme "MyScheme instead of xcodebuild -project "../MyProj.xcodeproj" -scheme "MyScheme"

What helped me is to use as here suggested:

defaults delete com.apple.dt.Xcode IDEPackageOnlyUseVersionsFromResolvedFile
defaults delete com.apple.dt.Xcode IDEDisableAutomaticPackageResolution

in ci_post_clone.sh script

xcodebuild not resolving local swift package dependencies
 
 
Q