pointfreeco / swift-identified-collections

A library of data structures for working with collections of identifiable elements in an ergonomic, performant way.
MIT License
531 stars 45 forks source link

[SPM] Dependencies could not be resolved in project that already imports `swift-collections` #5

Closed JUSTINMKAUFMAN closed 3 years ago

JUSTINMKAUFMAN commented 3 years ago

First of all, thank you for making this library! It's something I've thought about a number of times since starting with SwiftUI and am glad there's finally a solid implementation I can use.

There appears to be an issue importing this dependency via SPM in a project that already imports the swift-collections package (as mine does). I use OrderedDictionary for something unrelated to my use case for IdentifiedArray, but when I try to add the swift-identified-collections package to my manifest, I get the following error:

Dependencies could not be resolved because root depends on 'swift-identified-collections' 0.1.0..<1.0.0.
'swift-identified-collections' cannot be used because 'swift-identified-collections' depends on 'swift-collections' 0.0.4..<1.0.0 and root depends on 'swift-collections' 0.0.3.

Presumably, this is caused by the fact that your library also depends on swift-collections, and SPM doesn't let you import the same package twice.

If I am able to access OrderedDictionary transitively via swift-identified-collections, then that could be a way of solving this problem (I haven't tried yet), but I'd prefer to maintain a more descriptive manifest that imports both packages separately if at all possible.

swift-identified-collections-import-error

JUSTINMKAUFMAN commented 3 years ago

FWIW, I am able to import swift-collections.OrderedCollections.OrderedDictionary just fine when I import this package alone.

mbrandonw commented 3 years ago

This line here:

cannot be used because 'swift-identified-collections' depends on 'swift-collections' 0.0.4..<1.0.0 and root depends on 'swift-collections' 0.0.3.

explains the problem. It seems that your dependency on swift-collections states that it can only use 0.0.3 and ours says we can use anything from 0.0.4 up to (but not including) 1.0.0, and so it cannot find a version of the library in the intersection of those ranges.

I believe if you update your dependency to be 0.3.0..<1.0.0 you will be good to go.

stephencelis commented 3 years ago

This is also fixed in 0.1.1, if you're not ready to upgrade your other packages. Thanks!