Deprecation of NSNetService and alternatives

I've been working on a P2P networking framework recently (sending data to and from iPhones without needing a connection to the internet), starting with the numerous online tutorials on Multipeer Connectivity. I've been writing things up now using NSNetService due to the limitations of MPC. Looking at the developer pages, NSNetService is now deprecated. I'm a bit new to the networking side of Swift and iOS development, so I wanted to post a question here hoping to get some more information about what's going on/what's out there.

I have three main questions about this:

  • Why was NSNetService deprecated?
  • Will MPC be expanded to be more configurable to accomodate the deprecation?
  • What alternatives are there to send data over a local network without accessing the internet?

I've looked at the Network framework and it seems promising, but not sure if its the best route to take. I'm moreso asking just for overall knowledge of the networking ecosystem than a specific answer, so any clarifying context is helpful.

Answered by DTS Engineer in 678863022

Why was NSNetService deprecated?

Because:

  • In general, Network framework is the future of low-level networking on our platforms.

  • Starting with iOS 13 and friends, Network framework provides (almost [1]) all the functionality that NSNetService provided.

Will MPC be expanded to be more configurable to accomodate the deprecation?

I can’t discuss The Future™. If you’d like to see improvements to that API, I encourage you to file enhancement requests that describe your requirements.

If you do file any bugs, please post the numbers, just for the record.

Having said that, my experience is that many folks use Multipeer Connectivity for the wrong reasons. There’s a common misconception that Multipeer Connectivity is the only way to access Apple’s peer-to-peer Wi-Fi infrastructure. This is not true. You could always access it with NSNetService [2] and now you can also use Network framework.

As to whether you should use Multipeer Connectivity, I think that depends on your intended architecture. If your architecture is fully peer-to-peer — that is, none of the peers act as a single coordination point — then that’s a good fit for Multipeer Connectivity. If, however, your architecture is asymmetric — for example, you have one peer that acts as a server — then you’re better off with Network framework (or, on older platforms, NSNetService and NSStream).

What alternatives are there to send data over a local network without accessing the internet?

Network framework is the option that we recommend in general. If you want a more specific recommendation, please post more info about your goals.

Share and Enjoy

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

[1] The one exception is the ability to resolve a service, as discussed in this post.

[2] Indeed, the last time I checked Multipeer Connectivity was built on top of NSNetService.

Accepted Answer

Why was NSNetService deprecated?

Because:

  • In general, Network framework is the future of low-level networking on our platforms.

  • Starting with iOS 13 and friends, Network framework provides (almost [1]) all the functionality that NSNetService provided.

Will MPC be expanded to be more configurable to accomodate the deprecation?

I can’t discuss The Future™. If you’d like to see improvements to that API, I encourage you to file enhancement requests that describe your requirements.

If you do file any bugs, please post the numbers, just for the record.

Having said that, my experience is that many folks use Multipeer Connectivity for the wrong reasons. There’s a common misconception that Multipeer Connectivity is the only way to access Apple’s peer-to-peer Wi-Fi infrastructure. This is not true. You could always access it with NSNetService [2] and now you can also use Network framework.

As to whether you should use Multipeer Connectivity, I think that depends on your intended architecture. If your architecture is fully peer-to-peer — that is, none of the peers act as a single coordination point — then that’s a good fit for Multipeer Connectivity. If, however, your architecture is asymmetric — for example, you have one peer that acts as a server — then you’re better off with Network framework (or, on older platforms, NSNetService and NSStream).

What alternatives are there to send data over a local network without accessing the internet?

Network framework is the option that we recommend in general. If you want a more specific recommendation, please post more info about your goals.

Share and Enjoy

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

[1] The one exception is the ability to resolve a service, as discussed in this post.

[2] Indeed, the last time I checked Multipeer Connectivity was built on top of NSNetService.

Deprecation of NSNetService and alternatives
 
 
Q