Call to AXIsProcessTrustedWithOptions does not work after change setting manually

Hello all
I am testing accessibility permissions using AXIsProcessTrustedWithOptions
When app starts value is correctly returned. However if I change the setting in System Preferences -> Security & Privacy while app is running call to API is still returning the previous value.
Is that bug?
Here is example code:
Code Block
bool checkIfAccessibilityEnabledAndDisplayPopup()
{
  // Method to check if accessibility is enabled
  // Passing YES to kAXTrustedCheckOptionPrompt forces showing popup
  NSDictionary *options = @{(bridge id)kAXTrustedCheckOptionPrompt: @YES};
  Boolean accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
  return (!!accessibilityEnabled);
}
int main(int argc, const char * argv[]) {
  @autoreleasepool {
    NSLog(@"Starting");
    for (int i=0;i<100;i) {
       checkIfAccessibilityEnabledAndDisplayPopup();
       [NSThread sleepForTimeInterval:20.0f];
       NSDictionary *options = @{(__bridge id)kAXTrustedCheckOptionPrompt: @NO};
       Boolean b = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
       Boolean b1 = AXIsProcessTrusted();
       NSLog(@"accessibility AXIsProcessTrustedWithOptions--> %d AXIsProcessTrusted ---> %d", b, b1);
    }
}


Replies

No ideas? Hasn't anyone else seen this problem ?
If the application is sandboxed then AXIsProcessTrustedWithOptions will always return false. Additionally, you could see odd behavior if the application is not correctly signed with a developer cert.
That maybe the case since it is test application developed by myself to test behaviour of that. Can I expect odd behaviour even in my local laptop?
Yes, you will see odd behavior locally for an usigned app. Add code-signing with your developer identity/certificate and it should resolve. Do not enable the sanbox, just code-singing.
Bringing up this thread again. Using XCode and launching the binary from there, shows same problem
Can that be Apple bug?
I have tested the app signing the code and result is the same. It does not work. Can someone help me, please? To me it seems quite important bug. API does not work as described