AppleScript difference between scpt and app

I have the following Applescript XY.scpt which runs perfect from within the ScriptEditor. But after exporting it to an App (XY.app) it breaks with the message "System Events got an error: XY not allowed assistive access." (-1719)".

This is in Ventura 13.3 and the script XY is allowed for Accessibility and Automation in System Settings Security&Privacy.

set CR to ASCII character 13
set my0xC9 to ASCII character 201
tell application "Notes"
	activate
	set uiScript to "click menu item \"export as pdf" & my0xC9 & "\" of menu 1 of menu bar item \"File\" of menu bar 1 of application process \"Notes\""
	run script "tell application \"System Events\" " & CR & uiScript & CR & " end tell"
end tell

Thanks for your help, ideas and input!

Answered by DTS Engineer in 750186022

Where can I get the "stable code signing" certificate?

How you do this depends on your distribution strategy:

  • If this is something you’re creating yourself, you can use Xcode’s free provisioning support (aka Personal Team) to create an Apple Development signing identity that’ll work for this.

  • If you play to distribute this app widely, you’ll need to join a paid developer program and create a Developer ID Application signing identity.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

When you run your script in Script Editor, it piggybacks on top of Script Editor’s privileges. When you save a script as an app, it’s its own independent app and needs its own independent privileges. To make this work you’ll need to:

  1. Sign your app with a stable code signing identity. This system uses this to verify that version N+1 of your script is the ‘same code’ as version N.

  2. Grant it the accessibility privilege in System Settings > Privacy & Security > Accessibility.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Quinn Thanks a lot for your input. Unfortunately I was not yet successful! Your point (2) should be fine: I allowed this for Accessibility and also for Automation. But your first point still makes problems: I tried all options and Code Signs for exporting the script into an app. My most favorite "Don't Code Sign" did not work, nor did any other. My last hope: Where can I get the "stable code signing" certificate? Or do you have any other advice to work without certificate?

Accepted Answer

Where can I get the "stable code signing" certificate?

How you do this depends on your distribution strategy:

  • If this is something you’re creating yourself, you can use Xcode’s free provisioning support (aka Personal Team) to create an Apple Development signing identity that’ll work for this.

  • If you play to distribute this app widely, you’ll need to join a paid developer program and create a Developer ID Application signing identity.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Quinn

Thanks a lot for your help. I finally succeeded (after getting a free certificate via Xcode and managing to get the right settings in ScriptEditor for exporting my script to an App). I personally would prefer the option when exporting form Script Editor ("Don't Code Sign"). But this is not working - at least for me.

Nevertheless I would like to send you my feedback (for Apple): I appreciate the work Apple does, but requesting a registration and certificate to run some Apple Scripts on my own computer and only for me (and maybe some friends) is really over-engineered and goes imho into the wrong direction. Please do not build hurdles for enthusiast, children, and curious people!

So that we all can ..

.. ENJOY and share!

AppleScript difference between scpt and app
 
 
Q