Hello,
I'm implementing a custom VPN protocol for iOS by extending NEPacketTunnelProvider. But I noticed methods related to creation of sockets are deprecated in iOS 18.
NEProvider.createUDPSession(), NEProvider.createTCPConnection(), NWTCPConnection, NWUDPSession, NEPacketTunnelProvider.createUDPSessionThroughTunnel() and NEPacketTunnelProvider.createTCPConnectionThroughTunnel() are all deprecated.
What we need to use as an alternative to these methods? If there is an alternative, how can we specify to use tunnel or not when creating connection?
We have deprecated all of the In-Provider Networking APIs in favour of Network framework. This is inline with the advice from TN3151 Choosing the right networking API.
If you need to support older versions of iOS, it’s fine to continue to use the deprecated API. However, you should start to plan for the switch at some point.
In Network framework you have two options:
-
To create a connection that doesn’t go through the tunnel, use Network framework in the normal way. That’s the default behaviour for NE providers, as I explain in A Peek Behind the NECP Curtain.
-
To create a connection through the tunnel, fetch the
virtualInterface
property and apply that to therequiredInterface
property of yourNWParameters
object.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"