Robert Veringa
Robert Veringa

Reputation: 540

Xcode 15. Ambiguous type name 'NWEndpoint' in module 'NetworkExtension'

I'm running into some issues whereas Xcode 15.0 does not know what kind of NWEndpoint to use. I've pinpointed the problem and was able to easily reproduce it in any swift class.

Start with importing the following frameworks:

import Network
import NetworkExtension

After that you can declare and initialise a NWEndpoint object like this:

let nwEndpoint: NWEndpoint = NWHostEndpoint(hostname: "", port: "")

This will give you an error:

'NWEndpoint' is ambiguous for type lookup in this context

Usually this can be fixed by prefixing the object with the framework you want to use for that object like this:

let nwEndpoint: NetworkExtension.NWEndpoint = NWHostEndpoint(hostname: "", port: "")

However, you'll get a new error

Ambiguous type name 'NWEndpoint' in module 'NetworkExtension'

So I'm a bit lost on how to solve this build error. Any help would be appreciated.

Upvotes: 1

Views: 339

Answers (1)

Rastislav Kamenicky
Rastislav Kamenicky

Reputation: 51

For me it was solved by removing the:

import Network

And if I needed something from Network module (for example NWEndpoint), I prefixed it with

Network.

Network.NWEndpoint

Upvotes: 1

Related Questions