macOS get SSID changes?

I've had a little personal utility running for several versions of macOS that uses

let client = CWWiFiClient.shared()
if let ssid_name = client.interface()?.ssid() 

to get the current SSID name and prints it (along with a bunch of other active network details.

With the most recent Sonoma Beta 2 and Xcode beta 2, this always returns nil. Doing the same thing in a playground works as expected.
Is this a purposeful change or a bug I should file?

Answered by DTS Engineer in 758611022

I asked the CoreWLAN folks about this, and it looks like this was a deliberate change: Accessing the ssid property now requires the location privilege (r. 108641482).

We called this out in the header doc comments, where <CoreWLAN/CWInterface.h> now says:

SSID information is not available unless Location Services is enabled and the user has authorized the calling app to use location services.

I’d appreciate you filing a bug requested that the official docs be updated with that info.

Share and Enjoy

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

@eskimo @stenya Revisiting this after Sonoma 14.4 released: Now our workaround to call a bash script from the launchd daemon/agent is no longer working in Sonoma as well /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print $2}'

I have configured the Launch Agent with the Location Services prompt, and accepted it. Still calling the Apple CoreWLan APIs do not get me any Wifi ssid information that I need. Do we have any certified reccomendation from Apple on how to proceed?

My general advice is to not use a command-line tool when there’s an API equivalent. And doubly so when the command-line tool is buried deep in a framework rather than being on the default shell path.

Still calling the Apple CoreWLAN APIs do not get me any Wifi ssid information that I need.

Let’s start with some fundamentals:

  • Package your agent in an app-like wrapper.

  • Make sure it has a reasonable bundle ID.

  • Sign it with a stable code signing identity, like Apple Development.

Share and Enjoy

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

Just FYI: I reported a related issue using the feedback assistant and as of build 23E214,21T216 my issue is fixed. Maybe this helps!

The Sonoma update got me too.

I found that in terminal

networksetup getairportnetwork en0

will display the SSID as

Current Network: SSID

and in Python

import subprocess

wifi = subprocess.check_output(['networksetup', 'getairportnetwork', 'en0']).decode('utf-8') will return a string containing the SSID

macOS get SSID changes?
 
 
Q