Why do I need to keep re-enabled Accessibility for my mac whenever I compile a new version?

435 Views Asked by At

I have a macOS application that uses CGEventPostToPSN to send keyboard commands to TextEdit.

Whenever I compile a new version of the app, I'm unable to send keyboard commands.

I have to go into System Preferences -> Security -> Accessibility, then remove and re-add my application.

Every time I compile a new version.

Is there some way to circumvent this during development?

1

There are 1 best solutions below

0
pietrorea On

Yes, I worked on a project with this same problem. We never got around to doing it (disclaimer!), but our working theory was that if we enrolled in the Apple Developer Program and signed our development macOS builds with a Developer ID certificate, this problem will go away.

(The thinking was that it was probably Gatekeeper not being able to link one build to the next since there was no shared certificate for continuity.)

Note: This doesn't mean you have to distribute in the macOS App Store. You might look into notarization though.