Deprecation of NENetworkRule and NE

Question: Best Practice for NEFilterRule and NENetworkRule Initializers with Deprecated NEHostEndpoint?

Hi all,

I'm looking for guidance on the right way to construct an NEFilterRule that takes a NENetworkRule parameter. Reading the latest documentation, it looks like:

  • All initializers for NENetworkRule that accept an NEHostEndpoint are now deprecated, including initWithDestinationHost:protocol: and those using the various *Network:prefix: forms. NEHostEndpoint itself is also deprecated; Apple recommends using the nw_endpoint_t type from the Network framework instead.
  • However, NEFilterRule still requires a NENetworkRule for its initializer (docs).

With all NENetworkRule initializers that take NEHostEndpoint deprecated, it’s unclear what the recommended way is to create a NENetworkRule (and thus an NEFilterRule) that matches host/domain or network traffic.

What’s the proper way to construct these objects now—should we create the endpoints using nw_endpoint_t and use new/undocumented initializers, or is there an updated approach that’s considered best practice?

Helpful doc links for reference:

Answered by DTS Engineer in 851491022

AFAIK all the places where we deprecated NetworkExtension.NWEndpoint have a replacement based on Network.NWEndpoint. However, this can be quite tricky. I’ve explained this numerous times before, so I used your question as an excuse to write it up properly. See NWEndpoint History and Advice. The bulk of the post is backstory, but the last section covers your specific question.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

AFAIK all the places where we deprecated NetworkExtension.NWEndpoint have a replacement based on Network.NWEndpoint. However, this can be quite tricky. I’ve explained this numerous times before, so I used your question as an excuse to write it up properly. See NWEndpoint History and Advice. The bulk of the post is backstory, but the last section covers your specific question.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Deprecation of NENetworkRule and NE
 
 
Q