Hello guys,
In a macOS app developed with SwiftUI and swift, the NSAccessibility key has been added to the Info.plist file to explain why the app requires Accessibility permissions, and also the AXIsProcessTrustedWithOptions function has been called, but the app is not seen in the system's Accessibility list.
I thought, it will show up in the system's Accessibility list like following
Some of my code
import SwiftUI
@available(macOS 13.0, *)
@main
struct LOKIApp: App {
@State private var activeWindow: NSWindow? = nil
@State private var accessibilityGranted = false
var body: some Scene {
MenuBarExtra("App Menu Bar Extra", image: "trayicon") {
Button("Settings") {}
.keyboardShortcut("s")
Divider()
Button("Quit") {
NSApplication.shared.terminate(nil)
}
.keyboardShortcut("q")
}.menuBarExtraStyle(.menu)
}
init() {
let options: NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]
let accessibilityEnabled = AXIsProcessTrustedWithOptions(options)
if accessibilityEnabled == true {
print("Accessibility is enabled")
} else {
print("Accessibility is not enabled. Please enable it in System Preferences")
}
}
}
I didn't do any other configuration, and test this app by using the command Command+R, need I set provisioning profile? Please help, thank you.