How to prompt for accessibility features in a macOS app (from the AppDelegate)?
I realized this is an Xcode bug instead. This is caused if the SwiftUI preview provider is run concurrently with the actual build, this causes some confusion with the accessibility permissions with macOS.
The application works as expected after the derived data directory is cleaned. You can do that with
rm -rf ~/Library/Developer/Xcode/DerivedData
Persist accessibility permissions between builds in xcode 13
Figures I would solve this right after I post it.
The App needs to be signed with a certificate following this process to keep continuity between builds.
If your Apple ID is already hooked up to XCode and you have a developer account, I went to the "Signing and Capabilities" section in the App Targets section and updated "Signing Certificate" to "Development".
How to access accessibility settings in MacOSX Cocoa app using swift?
The kAXTrustedCheckOptionPrompt
type is Unmanaged<CFString>
so you need to access to the retained value as show below
let options : NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]
let accessibilityEnabled = AXIsProcessTrustedWithOptions(options)
Related Topics
Why Doesn't Swift Force My Designated Initializer to Call Super
Get Compiler Error in Swift Indexof()
Use Quick Look Inside a Swift Cocoa Application to Preview Audio Files
Create Endless Cgpath Without Framedrops
Swift 1.2 Not Working with Same Function Name and Different Parameter
Differencebetween Date.Addingtimeinterval(_:) and Date.Advanced(By:)
Need Explanation About Random Function Swift
Take Screenshot of Host App Using iOS Share/Action Extensions
Swift - Kvo - Change.Newvalue and Change.Oldvalue Are Nil
Update Nstouchbar on the Fly to Add/Remove Items Programmatically
How to Delete Object in Array of Dictionaries Using Key Value
How to Reference the View's Window in Swift 3.X Using Storyboards/Cocoa
Swift: Oslog/Os_Log Not Showing Up in Console App