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"

I've had a little personal utility

Is this a command-line tool? Or an app?

Share and Enjoy

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

Same issue here, my app uses CWWiFiClient.shared() to retrieve SSID name and it currently returns nil on macOS Sonoma beta 2

Putting this in a command line macOS app and a playground yield different results. The app prints unavailable, the playground prints the SSID name.

import Foundation
import CoreWLAN

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

print(ssid_name)

Same issue still here in Sonoma beta3.

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"

Is this problem solved? After I tried to get the location permission, it also return nil.

getting null even after adding the "com.apple.security.personal-information.location" entitlement, is there anything else to add in the entitlements. I have the below <key>com.apple.security.personal-information.location</key> <true/> <key>com.apple.security.network.client</key> <true/>

but still no luck.

Yes, I got it working with Location Services. I added a file for a LocationController and then in my main view added an onAppear(perform: { if LocationServices.shared.locationManager.authorizationStatus == .authorizedAlways { LocationServices.shared.userLocationDelegate = self } else { LocationServices.shared.locationManager.requestAlwaysAuthorization() } }) My code is up at https://github.com/ehemmete/NetworkView

Im still so confused on how to simply get a network SSID for a background application running DotNet Core on macOS now. Before, I could just call CWifiClient.networkInterfaces, now the value returns null. What steps do I need to take to enable this application which is signed with its own embedded provisioning profile? Do I detect if authorization is required, then request the prompt?

#if _UNIX

using System; using CoreWlan; using CoreLocation; //??? using ThreadNetwork;

namespace Amazon.PersistUserService.Controllers.NetworkController.NetworkChangeManager;

public class MacNetworkChangeManager: INetworkChangeManager { private readonly CoreWlan.CWWiFiClient networkClient; private CLLocationManager locationManager; //???

public MacNetworkChangeManager()
{
    networkClient = CWWiFiClient.SharedWiFiClient;
}

public string? GetConnectedSsid()
{
    //What do I add here to request authorization?
    
    foreach (var @interface in networkClient.Interfaces) // you can have multiple wifi devices connected at once
    {
        return @interface.Ssid;
    }
    return null;
}

} #endif

how to simply get a network SSID for a background application

What do you mean by “background application”? How is your program started?

Share and Enjoy

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

Hello @eskimo , my program is written in DotNet 6, and I use Xamarin.Mac SDK: https://learn.microsoft.com/en-us/dotnet/api/?view=xamarin-mac-sdk-14 Before as in my code, i was able to get the connected SSID without any issue. Now it returns null. Do I need to add an entitlement and prompt the user using Core Location? I'm not sure how to use it with Xamarin.Mac SDK in a dotnet application from the instructions here: https://developer.apple.com/documentation/corelocation/configuring_your_app_to_use_location_services

A launchd agent should be able to get this info. Is the agent associated with a standard GUI app? For example, you might be installing the agent from that app using SMAppService? Or is the agent a standalone thing?

Share and Enjoy

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

How do I use NSLocationAlwaysAndWhenInUseUsageDescription on macOS so that users know why I am requesting location?

Sorry, one more issue @eskimo : https://learn.microsoft.com/en-us/dotnet/api/corelocation.cllocationmanager?view=xamarin-ios-sdk-12 Corelocation API is only available for xamarin.ios is there an equivalent for macOS to use? I used @ehemmete approach to get my GUI to enable location information, but the launch agent is not able to fetch location information

The agent is associated with a standard GUI app

Cool. How do you install the the agent? SMAppService? Or something else?

CoreLocation API is only available for xamarin.ios is there an equivalent for macOS to use?

Core Location is supported on all our platforms. See the pills at the top of its main doc page. If that’s not reflected in your third-party tooling, I recommend that you raise this via its support channel.

Share and Enjoy

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

macOS get SSID changes?
 
 
Q