4

In OSX 10.9, I'm running the following code to see if my program is trusted:

 NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
 if(!AXIsProcessTrustedWithOptions((CFDictionaryRef)options))
   // Not trusted! ...

which opens the dialog to open System Preferences > Privacy > Accessibility to grant my application permission.

When I check the box to give my app permissions and run it again, my app still doesn't have permission and the checkbox is now unchecked.

Simply running AXIsProcessTrustedWithOptions appears to uncheck that box for some reason.

Kevin Colyar
  • 818
  • 1
  • 8
  • 18
  • Have you found a solution to this issue? The same issue is occurring for the app I'm working on. – Steffen Andersen Dec 05 '13 at 12:29
  • 1
    Hey, if you haven't found a solution to this issue, you might want to check this thread post -> https://devforums.apple.com/message/903480#903480 It helped me, also ensure you have everything codesigned and are not changing any files in the app bundle, as this will corrupt the codesigning and make AXIsProcessTrustedWithOptions reset for the your app. – Steffen Andersen Dec 10 '13 at 08:13
  • @SteffenAndersen so does that mean even i didn't change the bundle id and version (just changing build number), i should check for permissions because I change the code? – sftsz Mar 12 '15 at 10:09
  • @sftsz Your application should probably always check for permission, as the user could have changed it while the application wasn't running. – Steffen Andersen Mar 15 '15 at 13:27

1 Answers1

1

@Steffen, you're correct. Re-building the app does change the signature, and therefore needs to be trusted again.

I wrote a script that get's run before my app is executed in development rather than having to manually trust the app each time:

sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access values ('kTCCServiceAccessibility', 'com.company.app', 0, 1, 0, NULL);"
Kevin Colyar
  • 818
  • 1
  • 8
  • 18
  • This doesn't work for me in macOS 12.5.1 because I don't have permission to access the file. I think this is due to new OS hardening rules: I notice `.../com.apple.TCC` has the `com.apple.rootless` file system attribute. While I haven't tried it yet, https://stackoverflow.com/a/72312500/2219998 seems like it might work. – mcomella Dec 20 '22 at 01:50