I have a simple piece of demo code I am attempting to write for MacOS Yosemite that uses CoreWLAN to report on WiFi events. I've tried every combination I can think of Sandboxed, Signed, etc., all to no avail. Currently, I have the app set for Sandbox mode, and allowing outbound network connections in the entitlements. Any ideas as to how to get this to work? Sample code and scenario below:
import CoreWLAN
class WirelessMonitor: CWEventDelegate {
func registerForEvents() {
let client = CWWiFiClient.sharedWiFiClient()
client.delegate = self
var error:NSError?
puts("Registering for SSID change...")
client.startMonitoringEventWithType(.SSIDDidChange, error: &error)
if (error != nil) {
puts("error registering for SSID Change: \(error)")
}
}
func ssidDidChangeForWiFiInterfaceWithName(interfaceName: String!) {
print("ssid changed.")
}
}
When I run this, I receive an error upon calling startMonitoringEventWithType(...):
"Couldn’t communicate with a helper application." (The connection to service named com.apple.airportd was invalidated.)
In the MaOS console, I see this message:
7/18/15 12:19:11.753 AM sandboxd[504]: ([4105]) WiFi Debugger(4105) deny mach-lookup com.apple.airportd
At this point I’m going to have to revisit this issue in depth and that’s not something I can do in the context of DevForums.
It turns out that a different developer open a DTS tech support incident about this issue and that gave me an excuse to re-test.
CWWiFiClient
is definitely working for me an 10.13.4. The only oddity, and I suspect that this is what’s tripped you up, is that this API is now gated by the
com.apple.security.network.client
entitlement. Please make sure to enable that entitlement (Xcode > project editor > target > Capabilities > App Sandbox > Outgoing Connections (Client)) and retest.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"