Skip to content

Commit

Permalink
document macOS 14.4+ not working
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jun 6, 2024
1 parent e87f811 commit 0c69286
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ python -m mozloc.signal

### macOS

Note: macOS 14.4+ no longer works as "airport" has been removed.
If someone has time to implement, perhaps starting with example
[CoreLocation](./macos_corelocation.py)
code, we would welcome a PR.

On macOS, much more accurate results come by running as root by using sudo.
This is because "airport" only emits BSSID if running with sudo.

Expand Down
28 changes: 28 additions & 0 deletions macos_corelocation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# /usr/bin/env python3
"""
pip install pyobjc
from https://forums.developer.apple.com/forums/thread/748161?answerId=782574022#782574022
"""

import objc
import CoreLocation

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


bundle_path = "/System/Library/Frameworks/CoreWLAN.framework"

objc.loadBundle("CoreWLAN", bundle_path=bundle_path, module_globals=globals())

# https://developer.apple.com/documentation/corewlan/cwinterface
iface = CoreLocation.CWInterface.interface()

print(iface.interfaceName())
print(iface.ssid())

networks, error = iface.scanForNetworksWithSSID_error_(None, None)

for network in networks:
print(network.ssid())
5 changes: 4 additions & 1 deletion src/mozloc/airport.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
""" MacOS airport functions """
""" MacOS airport functions
Airport was removed from macOS 14.4+, so these functions no longer are relevant.
"""

from __future__ import annotations
import typing as T
Expand Down

0 comments on commit 0c69286

Please sign in to comment.