NEHotspotConfiguration not connecting to CoreWlan IBSS mode ad-hoc Wifi

I am trying to connect to a Wifi ad-hoc access point created on a Mac using NEHotspotConfiguration on iOS.


On the Mac, I use the CoreWlan framework to create an access point:

CWWiFiClient.shared().interface()!.startIBSSMode(withSSID: "Some SSID".data(using: .utf8)!,
                                                 security: CWIBSSModeSecurity.WEP104,
                                                 channel: 11,
                                                 password: "26f67a3045346b9587adeb9594")


On the iOS device, I use the NetworkExtension framework to connect to the given access point:

let hotspotConfiguration =  NEHotspotConfiguration(ssid: "Some SSID", passphrase: "26f67a3045346b9587adeb9594", isWEP: true)
NEHotspotConfigurationManager.shared.apply(hotspotConfiguration) { error in
    if let error = error {
        debugPrint(error)
     } else {
        debugPrint("no error")
    }
}

As expected, a dialog pops up asking the user to join the network.

After pressing "Allow" another dialog notifies that the connection failed.


The configuration is however succesfully added to the device.

This becomes evident as for one, the error parameter of the callback provided to apply is nil

and secondly connecting to the network from the iOS Wifi Settings manually afterwards works without entering the passphrase again.


The behavior is the same when using unprotected Wifi network.


I have verified that NEHotspotConfiguration is working with other Wifi networks.

I have verified that I can connect to to the Mac CoreWlan Hotspot manually in the iOS Wifi settings.

NEHotspotConfiguration in conjunction with the Mac CoreWlan Hotspot does not work.


Is there any information/documentation on using NEHotspotConfiguration with IBSS mode Wifi networks?


I also made a strange observation:

When killing and restarting the Hotspot with the same SSID, but different passphrase,

I can reconnect the iOS device to the Mac Hotspot from the Wifi settings without entering the new passphrase.

This makes me wonder if some Apple AirDrop/Bonjour service stuff is doing something under the hood,

preventing NEHotspotConfiguration to work as expected.


I have tested on iOS 13.3 and 13.4 Beta.


Possibly related:
https://forums.developer.apple.com/message/377360#377360

Replies

Related Feedback Report

https://feedbackassistant.apple.com/feedback/7636792

DTS Case ID: 732050292

I was able to reproduce this issue and followed up with Wireless Engineering on it; CoreWLAN's startIBSSMode is not recommended for this use case. As a workaround one could try using Internet Sharing on macOS but there is no public APIs for this and it would have to be configured manually.



Matt Eaton

DTS Engineering, CoreOS

meaton3 at apple.com