0

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?

Geesu
  • 5,928
  • 11
  • 43
  • 72
  • Every time you recompile the application, it is a completely different one as far as the system is concerned - one that has not been given accessibility permissions. Not really a way around it, as that would defeat the purpose. – red_menace Sep 04 '21 at 20:05
  • Duplicate of [MacOS Accessibility API not working after change in code and new build (Xcode/Swift simulating keyboard input)](https://stackoverflow.com/questions/63917186/macos-accessibility-api-not-working-after-change-in-code-and-new-build-xcode-sw). – Willeke Sep 05 '21 at 07:45
  • Does this answer your question? [Accessibility permissions reset after application update](https://stackoverflow.com/questions/29006379/accessibility-permissions-reset-after-application-update) – Willeke Sep 05 '21 at 07:45

1 Answers1

0

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.

pietrorea
  • 841
  • 6
  • 14