I noticed that NetService
and NetServiceBrowser
have been
deprecated as of iOS 15. Is there a new means to establish Wi-Fi
Direct connections and share data with peers?
[While this is orthogonal to your actual issue, I want to reiterate a point from my first response on this thread: The peer-to-peer Wi-Fi networking supported by Apple platforms is not Wi-Fi Direct.]
As to the deprecation you mentioned, the <Foundation/NSNetServices.h>
header says:
API_DEPRECATED("Use nw_connection_t or nw_listener_t in Network framework instead", macos(10.2, API_TO_BE_DEPRECATED), ios(2.0, API_TO_BE_DEPRECATED), tvos(9.0, API_TO_BE_DEPRECATED)) API_UNAVAILABLE(watchos)
@interface NSNetService : NSObject {
…
}
…
API_DEPRECATED("Use nw_browser_t in Network framework instead", macos(10.2, API_TO_BE_DEPRECATED), ios(2.0, API_TO_BE_DEPRECATED), tvos(9.0, API_TO_BE_DEPRECATED)) API_UNAVAILABLE(watchos)
@interface NSNetServiceBrowser : NSObject {
…
}
In short, these APIs were deprecated in favour of Network framework.
It’s annoying that these deprecation notes aren’t surfaced in the documentation. This came up recently in another content and I coulda sworn I filed a bug about that, but I can’t find it in my records so I’ve just file one right now (r. 85246804).
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"