CWWiFiClient scanForNetworks(withSSID: nil) sometimes returns all SSIDs as nil

Hi Quinn,

I have a macOS App (SwiftUI) which scans for available WifiNetworks using

CWWiFiClient.shared().interface().scanForNetworks(withSSID: nil)

The app is sandboxed and has "Outgoing Connections" (Client) checked.

The app is Launched via a "LaunchAgents".

During app init() I kickoff the scanForNetworks in a background thread. I do receive WifiNetworks but when I look at the SSID quite often all of the SSIDs are nil.

If I loop the scanForNetworks() a few times with a delay of 1 second after a few tries the SSIDs will no longer be nil.

Any idea why this happens? Should I file a bug report or is that expected behavior

Thanks very much,

Martin (your old friend from Germany)

Replies

Heya to you to!

Is this behaviour correlated with a recent OS release? Like macOS 13? Or 14? Or are you seeing it all the way back?

Share and Enjoy

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

Hi Quinn,

We have tested this on macOS 13 and macOS 14 and it looks like the issue only happens with macOS 14 (Sonoma).

Thanks,

Martin

OK. There have been multiple privacy-related change to Core WLAN in recent releases:

  • A while back (macOS 10.15 I think) Core WLAN started requiring location permission to get detailed scan results.

  • In macOS 14 it now requires location permission to get the current Wi-Fi network. See this thread.

I’m not exactly sure how that correlates with the problems you’re seeing, but the take-home point is that you’ll need to make sure your agent has location privileges.

Share and Enjoy

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