I don't understand what permissions need to be given for this code to operate. I cannot seem to work out why I'm not able to see a BSSID.
I think I've given sandbox the appropriate permissions AND I've added some to the Target Properties for good measure. Yet, cannot get BSSID.
import SwiftUI import CoreWLAN import CoreLocation struct ContentView: View { @State private var currentBSSID: String = "Loading..." var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) Text("Current BSSID:") Text(currentBSSID) } .padding() .onAppear(perform: fetchBSSID) } func fetchBSSID() { if let iface2 = CWWiFiClient.shared().interface() { print("✅ Found Wi-Fi interface: \(iface2.interfaceName ?? "nil")") } else { print("❌ No Wi-Fi interface found") } if let iface = CWWiFiClient.shared().interface(), let bssid = iface.bssid() { currentBSSID = bssid } else { currentBSSID = "Not connected" print("✅ BSSID: \(currentBSSID)") } } } #Preview { ContentView() }
Output - WifI interface is found but BSSID is not found.
If you care about user privileges, as set in System Settings > Privacy & Security, don’t use Sign to Run Locally. That results in an ad-hoc signature, which means your code has no designated requirement, which means the system can’t track the privilege from one build of your app to the next. See TN3127 Inside Code Signing: Requirements for more about this.
Instead, choose an Apple Development signing identity.
Beyond that, you are correct that getting the BSSID requires you to have the Location privilege. You wrote:
What do you mean by “run it in Xcode”? Are you choosing Product > Run? Or are you talking about the SwiftUI preview?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"