I can't add any swift packages using SPM. this includes any of the Apple Swift packages, or any other packages from github.
For example, attempts to add the swift-collections package (using File > Add Packages...) shows the following prompt:
Package Resolution Failed
swift-collections could not be resolved.
Fetching from https://github.com/apple/swift-collections.git (cached)
Cloning local copy
Checking out 1.0.3
Couldn't update repository submodules:
Image of prompt
If I choose "Add Anyway", the project can still build successfully if I don't import the module. The package dependency is listed in the .xcodeproj file. However, importing the module will not work (No such module 'Collections').
The following un-categorized buildtime issue is consistent no matter what package I try to add:
Couldn't update repository submodules:
/Users/username/Downloads/Xcode.app/Contents/Developer/usr/libexec/git-core/git-submodule: line 7: basename: command not found
/Users/username/Downloads/Xcode.app/Contents/Developer/usr/libexec/git-core/git-submodule: line 7: sed: command not found
/Users/username/Downloads/Xcode.app/Contents/Developer/usr/libexec/git-core/git-sh-setup: line 86: basename: command not found
/Users/username/Downloads/Xcode.app/Contents/Developer/usr/libexec/git-core/git-sh-setup: line 86: sed: command not found
/Users/username/Downloads/Xcode.app/Contents/Developer/usr/libexec/git-core/git-sh-setup: line 333: uname: command not found
/Users/username/Downloads/Xcode.app/Contents/Developer/usr/libexec/git-core/git-submodule: line 954: sed: command not found
/Users/username/Downloads/Xcode.app/Contents/Developer/usr/libexec/git-core/git-submodule: line 954: cmd_: command not found
I'm not sure what this means, because all of the commands above (basename, sed, uname) seem to work in the terminal.
I've tried Xcode 13.4.1,Xcode 14.0, Xcode 14.0.1, which all have the same issue.
I have also reset my ~/.gitconfig to default and reinstalled Xcode command line tools.
And I have tried the solution to a similar but seemingly unrelated problem:
git config --global tag.forcesignannotated false
I tried using all 4 different dependency rules while adding the package.
Finally, I tried deleting all derived data, remove the package, add it back and rebuild the project.
First, try removing ~/Library/Caches/org.swift.swiftpm/, this will remove package caches.
Second, try resolving packages in the command line by executing xcodebuild -resolvePackageDependencies in the root of the directory.
Yesterday i had this weird bug 'Couldn't update repository submodules.' in my xcode and also another error saying 'Missing package product 'Package'' while that package was already present. I tried Clean the build folder, resetting the cache, resolving packages and update packages to latest. I even recloned the repo and reinstalled the Xcode. Nothing worked for me. After debugging for couple of hours i was able to solve it by doing the following steps:
xcodebuildFor me this happened in XCode 14.3.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With