Xcodebuild Update to Latest Package Versions

Hi all,

I would like to obtain the same result as Xcode's Update to Latest Package Versions.

I have tried to use:
xcodebuild -scheme SchemeName -resolvePackageDependencies
However it doesn't appear to always work...