Our application (sandboxed, on the mac) sends Apple Events to itself for being recordable in Script Editor.
Alas, I just noted that this feature stopped working, i.e. at least under macOS 12.4 Script Editor does not see what our application does. I am not sure when (i.e. under what macOS) recordability stopped working, but it is gone on 12.4.
We have tried, (for testing), to set the sandbox exception com.apple.security.temporary-exception.apple-events to true, but it makes no difference.
I know that Apple Script in general, and recordability in particular, are badly out of fashion these days, so we are considering dropping recordability anyway. But if there's an easy way to keep it working, I'd be interested.
Thanks for any advice in advance
Okay, I spent an inordinate amount of blood, sweat, and tears reading the archived (i.e. obsolete) documentation as well as the cryptic modern one. I also checked what other apps do. Finally, I have been able to make recording work. In case anyone ever tries to make their application recordable, here's what I've found out:
In order to be recordable by Script Editor, an application needs to have the following entries in its entitlements file:
<key>com.apple.security.automation.apple-events</key>
<true/>
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.ScriptEditor2</string>
</array>
In addition, and this was the hardest part, it also needs to explain why it wants to send Apple Events to Script Editor. And this explanation has to go into the application's info.plist file under the NSAppleEventsUsageDescription key, e.g. something like this:
<key>NSAppleEventsUsageDescription</key>
<string>xxxxx needs to send Apple Events to Script Editor to allow Script Editor to record what you do in xxxx</string>
(Without the NSAppleEventsUsageDescription, Script Editor never gets any Apple Events it can record. Once you have entered this and you operate your app while Script Editor is recording, a dialog box will come up that asks the user to confirm that the app is allowed to send Apple Events to Script Editor. Once the user confirms, the setting is reflected in System Preferences -> Security & Privacy -> Privacy -> Automation)
Finally, here are some useful hints for debugging:
When you change any of the above entries in order to see how your app behaves after the change, it's a good idea to reset the system's privacy settings using tccutil
in Terminal:
tccutil reset AppleEvents your_bundle_id
If you want to peek at the entitlements of your or any other app, use codesign
in Terminal:
codesign -d --entitlements - path_to_your_app
I hope this helps someone out there.
Now for the next challenge: Getting the entitlements through the App Store Review. (I am not too optimistic.)