SPM Package resolution doesn't handle different URLs to the same dependency

Originator:crayment16
Number:rdar://FB9026259 Date Originated:March 2, 2021
Status:Open Resolved:
Product:Swift Compiler Product Version:
Classification:Incorrect/Unexpected Behavior Reproducible:
 
Please describe the issue:

SPM supports both of these formats for dependencies:

.package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMinor(from: "3.1.1"))
.package(url: "https://github.com/daltoniam/Starscream", .upToNextMajor(from: “3.1.0”))

Notice that one is using a trailing “.git” and one isn’t. When I depend my app on two dependencies, and they each in turn depend on a 3rd dependency - but specified with different URLs, dependency resolution fails with an error like: “Missing package product 'Starscream’”

This error does not seem to occur when adding these dependencies to a project directly through Xcode. But it does when adding them to your own package via a Package.swift.


Please list the steps you took to reproduce the issue:

1. Open Xcode and create a new package: File -> New -> Swift Package...
2. You can leave name MyLibrary. Save it somewhere.
3. Open the Package.swift inside of the new MyLibrary package.
4. Add the following platforms section below the name lines

platforms: [
    .iOS(.v14),
    .macOS(.v11)
],


5. Add the following 2 lines to the dependencies section. Note I am using exact versions so this should continue to work consistently.

.package(name: "Apollo", url: "https://github.com/apollographql/apollo-ios.git", .exact("0.41.0")),
.package(name: "AbsintheSocketTransport", url: "https://github.com/aj-foster/absinthe-socket-transport.git", .exact("0.0.1")),


6. Add the two products to the dependencies section of the MyLibrary target. See attached project for what your final Package.swift should look like.

.product(name: "Apollo", package: "Apollo"),
.product(name: "AbsintheSocketTransport", package: "AbsintheSocketTransport"),


7. Try to build the MyLibrary target. For Mac or iOS. They both will fail with the error: “Missing package product 'Starscream’”


What did you expect to happen?

Apollo depends on Starscream with .upToNextMinor(from: "3.1.1") 
absinthe-socket-transport depends on SwiftPheonixClient 1.3.0 which depends on Starscream with .upToNextMajor(from: "3.1.0")

I would expect Xcode to understand that it can use Starscream 3.1.1 and use it, compiling without errors.


What actually happened?

Dependency resolution kinda seems to complete, but compiling fails with the error:

Missing package product 'Starscream’”

Starscream 3.1.1 does seem to be cloned into the checkouts folder in derived data, but Xcode isn’t using it for some reason. When I fork Apollo and change it to use the “.git” suffix on the Starscream dependency, then things work as expected.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!