apple / swift-nio-transport-services

Extensions for SwiftNIO to support Apple platforms as first-class citizens.
https://swiftpackageindex.com/apple/swift-nio-transport-services/main/documentation/niotransportservices
Apache License 2.0
286 stars 74 forks source link

Cannot get NIO transport services to resolve - still not working :-( #121

Closed drekka closed 3 years ago

drekka commented 3 years ago

I have the following fragment in my package file:

    dependencies: [
        .package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.1.1")
    ],
    targets: [
        .target(
            name: "Simulcra",
            dependencies: ["swift-nio-transport-services"],
        ),

But it won't resolve, telling me "product 'swift-nio-transport-services' required by package 'simulcra' target 'Simulcra' not found."

How do I get this to work?

Davidde94 commented 3 years ago

Which Xcode/Swift are you using?

Lukasa commented 3 years ago

Can you also show the first line of the Package.swift, which defines your tools version?

Lukasa commented 3 years ago

Oh, nevermind, the dependency specification is not right. You have to specify a product as your dependency, but swift-nio-transport-services is a package. We define only one product:

https://github.com/apple/swift-nio-transport-services/blob/47fddadf831e78972fcb9d845bcd148992958f54/Package.swift#L20-L22

Change the dependency name to NIOTransportServices and you should be fine.

drekka commented 3 years ago

Hi @Lukasa Thanks for replying. I'm using swift tools version 5.5 in Xcode 13 beta. I already tried using "NIOTransportServices" as the reference and it insisted that to do that I had to add the name to the dependency, so I tried this:

    dependencies: [
        .package(name: "NIOTransportServices", url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.0.0")
    ],
    targets: [
        .target(
            name: "Simulcra",
            dependencies: ["NIOTransportServices"],
        ),

But now it's giving this error:

'simulcra' dependency on 'https://github.com/apple/swift-nio-transport-services.git' has an explicit name 'NIOTransportServices' which does not match the name 'swift-nio-transport-services' set for 'https://github.com/apple/swift-nio-transport-services.git'

Any Idea?

SPM is a new experiment for me so I don't know all the tricks :-)

drekka commented 3 years ago

BTW, NIO and NIO Transport Services are resolving and I can see them in Xcodes dependencies, browse their package files and source. So that's working. It's just trying to get them to resolve when I add them as a dependency that's causing the problem. Note I'm also not specifying NIO, as it appears that Transport Services is dealing with it for me.

Davidde94 commented 3 years ago

I would suggest trying to use the full `.product(name: "NIOTransportServices", package: "swift-nio-transport-services") syntax

Lukasa commented 3 years ago

Following up on @Davidde94’s comment you also need to clean up your dependencies stanza. You want to end up with:


    dependencies: [
        .package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.0.0")
    ],
    targets: [
        .target(
            name: "Simulcra",
            dependencies: [.product(name: "NIOTransportServices", package: "swift-nio-transport-services")],
        ),
drekka commented 3 years ago

I figured it out eventually. I was miss-reading one of the error messages.