macOS error when running AppleScript in a stack on a server

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
japino
Posts: 78
Joined: Sun Oct 14, 2012 10:56 am

macOS error when running AppleScript in a stack on a server

Post by japino » Fri May 08, 2020 5:09 pm

I'm working on a small project for myself and a few other people.
I'm using a launcher stack saved as a standalone.
This launcher opens a Livecode stack which resides on a server. The stack loads and runs fine.

However, the stack tries to run a small Applescript at some point and some people, mostly on macOS Mojave, then run into macOS error -67062 (as visible in Console) and the Applescript does not run.

macOS error -67062 has to do with unsigned code, so I tried code-signing and notarizing the app to see if that helped. Code-signing and notarizing eventually worked, but now the funny thing is that I'm running into this error myself on my own machine with the code-signed app. No problem with the unsigned app. What I also find very peculiar is that some people are running into this issue and others are not.

For what it's worth, the AppleScript in question is just a few lines long and uses System Events to type a keyboard shortcut in another application. The AppleScript gets the name of the application from the stack (the same shortcut is to be used in any of 5 different applications).

I tried to see if I could get some more information about the error by using this, but no luck, no error is returned:

Code: Select all

         try
            do myAppleScript as Applescript
         catch someError
            answer "An error ocurred:" && someError
         end try      
I've already spent a few good hours on this, but I'm still confused... Hope anyone can point me in the right direction...

japino
Posts: 78
Joined: Sun Oct 14, 2012 10:56 am

Re: macOS error when running AppleScript in a stack on a server

Post by japino » Sun May 10, 2020 12:08 pm

Still trying to get to the bottom of this. I'm now using a standalone application and no longer using a launcher application and a livecode file on a server. I've signed the app, but my AppleScript which is sending System Events does not work. Console shows me this:
"Since sending application [sess=100007 pid=1003 uid:501,501,501 g:20,20 pV:2355] is not permitted to send this AppleEvent to this process, returning an errAEEventNotPermitted reply."

japino
Posts: 78
Joined: Sun Oct 14, 2012 10:56 am

Re: macOS error when running AppleScript in a stack on a server

Post by japino » Sun May 10, 2020 12:40 pm

After disabling System Integrity Protection, the problem is gone... But I don't really want to tell people: "Hey, if you want to use this tool, please disable System Integrity Protection"... :roll:

japino
Posts: 78
Joined: Sun Oct 14, 2012 10:56 am

Re: macOS error when running AppleScript in a stack on a server

Post by japino » Mon May 11, 2020 8:05 am

OK, some more in this talking-to-myself topic. Looks like I might need an Entitlements file with com.apple.security.automation.apple-events set to true. Will explore that route further. Not sure how to do that easily in LiveCode. Read something about Levure, but it seems a lot of overkill. Will explore further when I have more time.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9578
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: macOS error when running AppleScript in a stack on a server

Post by dunbarx » Tue May 19, 2020 1:05 am

Hi.

Post this on the "Talking LiveCode" pane. More attention paid there.

Craig

japino
Posts: 78
Joined: Sun Oct 14, 2012 10:56 am

Re: macOS error when running AppleScript in a stack on a server

Post by japino » Tue May 19, 2020 4:19 pm

Thanks for the suggestion Craig, I may do that eventually!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: macOS error when running AppleScript in a stack on a server

Post by FourthWorld » Tue May 19, 2020 4:27 pm

It's a macOS-specific issue, so you chose the right place. Let's please not turn other sections into a catch-all for perceived popularity. I don't want to clean up the duplicate threads, and most folks use the "New Posts" link anyway so whether it's here or there matters less than if the thread has been posted to recently and if folks think they can help with it.

Japino, earlier you wrote: " I might need an Entitlements file with com.apple.security.automation.apple-events set to true."

Did you do that? Apple has been increasing security, and since AppleScripts lets a program control other programs it seems like exactly the sort of thing they'd want to make as safe as possible.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

japino
Posts: 78
Joined: Sun Oct 14, 2012 10:56 am

Re: macOS error when running AppleScript in a stack on a server

Post by japino » Fri May 29, 2020 9:36 am

Yes, I added the entitlements file and signed my app with it. I also checked if the entitlements were in the app with this command and they were:

Code: Select all

codesign -d --entitlements :- /Applications/MyApp.app 
Executable=/Applications/MyApp.app/Contents/MacOS/MyApp
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>com.apple.security.automation.apple-events</key>
  <true/>
</dict>
</plist>
On my test machine, the app does not show up in System Preferences > Security & Privacy > Automation (as I would have hoped), but I have to check this again on another machine with SIP on to see if I then get a macOS message asking me if I will allow System Events from the app. I'm hoping that the app will then show up in System Preferences.

Post Reply

Return to “Mac OS”