Consistent spm dependency versions in Xcode project


Is there a way to define version numbers for each remote swift package dependency in a shared place? The idea is to use same version of a remote package across multiple local swift packages rather than each local swift package specifying which version it should be using.

This is to avoid an accidental dependency on a wrong version.

One way I think of (didn't try yet) is environment variable but not sure if Xcode Xcode can help with that.

Thank you for response in advance!


Somebody posted same question here ios - Same version of swift package in all local packages - Stack Overflow but there is no (satisfying) answer.

Interesting find.. this mayn't be a concern because main Xcode project throws following warning (message is not clear but it works I think):

Dependencies could not be resolved because root depends on 'FooPackage' 1.104.0 and root depends on 'FooPackage' 1.105.1.

I wouldn't know of a way to do that, but maybe you can just run the same "update script" on all of your local packages. See this Github action for example. This would update all of your dependencies though, but could give you a start.

It would be nice though if such a feature would be supported.

1 Like