CoreWlan network scan returns nil BSSID in a command line application when location authorization is granted

This is specific for MacOS 10.15 beta


It is known (however, not described well in the documentation) that CoreWLAN scans require location services to be enabled since 10.14. Beta of 10.15 enforces this even further, requiring explicit application location authorization. But scans stil has nil BSSID even with location authorization granted in case if the application is a command line one.


Steps to reproduce:

- Create a *command line* application in Xcode

- Create a location manager and request authorization

- Make sure location services are enabled and authorization is granted

- Wait for a core location authorization status kCLAuthorizationStatusAuthorizedAlways

- After that, issue CoreWLAN networks scan with scanForNetworksWithSSID:nil error:&err]


As a result, you will get a scan result, but all BSSIDs will be nil. Just like when there is no location enabled or no auth. Same setup in Cocoa application produces a good scan with populated BSSIDs


With additional experimenting it was found, that it may be related to a workaround that "locationd" service uses to store authorization status for non-bundled binaries. Specifically, locationd stores auth status in /var/db/locationd/clients.plist. And while usual app bundles are referenced there using their bundle id, for command line tools, bundle id is generated presumably by locationd, using a path to a binary, for example: “com.apple.locationd.executable-/Users/noco/testbinary”. And for CoreWLAN, when it checks location auth, it seems to be not using that trick with generated bundle id, and without real bundle id from Info.plist it is unable to auth scan requests even when CoreLocation/locationd are authorised to pass location to command line binary.


I filed an issue via Feedback Assistant regarding this, but its status did not change since that. Anyone else is affected by this issue? Any workarounds, or other thoughts?


Thanks in advance!

Replies

You said "Same setup in Cocoa application produces a good scan with populated BSSIDs". I'm facing with the issue in a macOS App project. I have chosen "Location" in "Signing & Capabilities" -> "App Sandbox" -> "App Data", but it doesn't work. Have I misunderstood something?

You also have to request location authorization explicitly, by calling requestAlwaysAuthorization() - CLLocationManager | Apple Developer Documentation and wait for location auth status update in the delegate

Has there been any traction on this? I recently started to get into developing command line tools for the Mac and I ran into this bug right away. Not sure if I should even bother now.