Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package dependency conflicts cause XCode build to fail #27

Closed
jbilbro01 opened this issue May 17, 2023 · 0 comments
Closed

Package dependency conflicts cause XCode build to fail #27

jbilbro01 opened this issue May 17, 2023 · 0 comments

Comments

@jbilbro01
Copy link

jbilbro01 commented May 17, 2023

Using XCode 14.2 and DNSClient 2.3.2
When resolving the packages and dependencies, XCode runs into a problem with the NioDNS package. The error message is as follows:

'niodns' dependency on 'https://github.com/Joannis/swift-nio-transport-services.git' conflicts with dependency on 'https://github.com/apple/swift-nio-transport-services.git' which has the same identity 'swift-nio-transport-services'. this will be escalated to an error in future versions of SwiftPM.

XCode seems to resolve the dependency graph without error, but this causes the underlying code from the DNSClient package to stop working. In the swift file "DNSClient+Connect," it can no longer find the reference "NIOTSDatagramBootstrap".

Specifically, the error occurs in the DNSClient extension:

extension DNSClient {
    /// Connect to the dns server using TCP using NIOTransportServices. This is only available on iOS 12 and above.
    /// - parameters:
    ///   - group: EventLoops to use
    ///   - config: DNS servers to use
    /// - returns: Future with the NioDNS client. Use 
    public static func connectTS(on group: NIOTSEventLoopGroup, config: [SocketAddress]) -> EventLoopFuture<DNSClient> {
        guard let address = config.preferred else {
            return group.next().makeFailedFuture(MissingNameservers())
        }


        let dnsDecoder = DNSDecoder(group: group)
        
        return NIOTSDatagramBootstrap(group: group)
            .channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)
            .channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEPORT), value: 1)
            .channelInitializer { channel in
                return channel.pipeline.addHandlers(dnsDecoder, DNSEncoder())
        }
        .connect(to: address)
        .map { channel -> DNSClient in
            let client = DNSClient(
                channel: channel,
                address: address,
                decoder: dnsDecoder
            )

            dnsDecoder.mainClient = client
            return client
        }
    }
    /// Connect to the dns server using TCP using NIOTransportServices. This is only available on iOS 12 and above.
    /// The DNS Host is read from /etc/resolv.conf
    /// - parameters:
    ///   - group: EventLoops to use
    public static func connectTS(on group: NIOTSEventLoopGroup) -> EventLoopFuture<DNSClient> {
        do {
            let configString = try String(contentsOfFile: "/etc/resolv.conf")
            let config = try ResolvConf(from: configString)

            return connectTS(on: group, config: config.nameservers)
        } catch {
            return group.next().makeFailedFuture(UnableToParseConfig())
        }
    }
}
@jbilbro01 jbilbro01 closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant