Swift Package Manager - Resolve Package Versions terminal command

I want to replace cocoapods with SPM. I have decided to go at it one library at a time. I removed the swinject library from cocoapods and added it via File->Swift Packages->Add Package Dependency

This was successful and the project built and ran as expected.

enter image description here

I then asked other people in my team to check out the branch and see if they can build the project on their side without issues. We then ran into the error "Missing package product 'Swinject'". We resolved this error by performing File->Swift Packages->Resolve Package Versions in Xcode.

I need to get this working on the build server as well. I tried typing in swift package --help in the Terminal app to see what commands are available. The resolve command looked promising so I tried that to no avail. (error: root manifest not found)

So, my question then, is there a terminal command that does the same as File->Swift Packages->Resolve Package Versions?

Note: When I added the 3rd party library via SPM, it created one file for me: Proj.xcworkspace/xcshareddata/swiftpm/Package.resolved. It also made various changes to the Proj.xcodeproj/project.pbxproj file. No package.swift file was created.

I believe the command you're looking for is:

xcodebuild -resolvePackageDependencies
1 Like

I think there is still some difference. When I do xcodebuild -resolvePackageDependencies I still get build errors after that when I try to run the app. But File->Swift Packages->Resolve Package Versions fixes the issue. So it seems that they are not exactly the same.

Was there any workaround for this? the command below gives the same error, even specifying the workspace and the scheme fails.
xcodebuild -resolvePackageDependencies

Sorry, I didn't find any workaround.

1 Like

Thanks, for getting back.