CoreWLAN returning null SSID with PyObjC on MacOS 14.4 with Location Services enabled

I have a Python script that returns a scan result with scanForNetworksWithName using CoreWLAN with PyObjC. It provides info on ssid and such like the airport command.

When upgrading to MacOS 14.4 however SSID is now Null. I read this was due to changes in permissions and location services needed to be enabled.

I have enabled access to location services and I am able to use CoreLocation to get a location however I still do now see the SSID.

Here is my script, that does both location and scan:

import CoreWLAN
import CoreLocation
from time import sleep
import re

wifi_interface = CoreWLAN.CWInterface.interface()
networks, error = wifi_interface.scanForNetworksWithName_error_(None, None)

location_manager = CoreLocation.CLLocationManager.alloc().init()
location_manager.startUpdatingLocation()

max_wait = 60
# Get the current authorization status for Python
for i in range(1, max_wait):
    authorization_status = location_manager.authorizationStatus()
    if authorization_status == 3 or authorization_status == 4:
        print("Python has been authorized for location services")
        break
    if i == max_wait-1:
        exit("Unable to obtain authorization, exiting")
    sleep(1)

coord = location_manager.location().coordinate()
lat, lon = coord.latitude, coord.longitude
print("Your location is %f, %f" % (lat, lon))

print(f"{'SSID' : >32} {'BSSID' : <17} RSSI CHANNEL HT CC SECURITY")
for i in networks:
print(f"{'SSID' : >32} {'BSSID' : <17} RSSI CHANNEL HT CC SECURITY")
for i in networks:
    print(f"{i.ssid() or '' : >32} {i.bssid() or '' : <17} {i.rssiValue() : <4} {i.channel() : <6}")

It worked fine in MacOS 13.6 but with MacOS 14.4 I have the null SSID issue.

We went through something similar with MacOS 10.15 where BSSID became Null. At the time I couldn't find a workaround, but sometime around MacOS 13.x I was able to generate the request for location services. After granting the request I was able to see BSSID again. It seems like we have a similar bug to this again.

Thread about the BSSID issue: https://github.com/ronaldoussoren/pyobjc/issues/484

Post not yet marked as solved Up vote post of thewade Down vote post of thewade
387 views

Replies

Is this a change in macOS 14.4? That is, did this work on previous versions of macOS 14?

I don’t think it would have, because of the change discussed in this thread.

Share and Enjoy

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

I was able to test MacOS 14.1.2 and 14.2 today and I am seeing the same issues.

I tested with the Python 3.8.18, 3.9.18, 3.10.13, and 3.11.8 downloaded with Brew as well as Python 3.9.6 distributed by Apple with the command line developer tools.

I have noticed that even without the proper permissions Python 3.9 distributed by Apple can access the SSID. Enabling the permissions it can also access location and BSSID. This applies to MacOS 14.1, 14.2 and MacOS 14.4 and matches the behavior in MacOS 13.

As for the Python versions distributed by Brew, I am getting inconsistent results. Testing MacOS 14.1 and 14.2, I was able to access location with all Python versions, however I was never able to get SSID or BSSID. Testing MacOS 14.4 I was able to get SSID and BSSID with some versions after granting permissions but not others. In my testing 3.8 and 3.9 worked and 3.10 and 3.11 did not, but this might not be consistent as it was previously not working.

In MacOS 13.6 I was able to get location, SSID, and BSSID with Python 3.8, 3.9, 3.10, and 3.11 from Brew and Python 3.9 from Apple.

Note that there are two mistakes in the script I posted. The scan on line 6-7 should be after authorization and lines 27-28 were duplicated by mistake.

I retested MacOS 14.4 on a different computer after upgrading it from MacOS 14.1.2 and hit a new inconsistency. Even with the correct permissions Python 3.9 distributed by Apple was able to print the SSID and location but not BSSID. And with all the brew versions I was unable to print SSID and BSSID matching my previous testing of 14.1 and 14.2.

I am experiencing the same inconsistency.

I have two Macs both running macOS 14.4.1, both Python3.12.2 installed via brew, and both with Python authorised for Location Services. However, only one of the Macs is able to display the SSID and BSSID; the other failed to display either (showing None instead).

Did you manage to find a solution to this issue?