System Events on XCode error 1743

Hi guys,

someone else has encountered this error with XCode 10 and Mojave? A simple fragment of code, that works fine on applescript, fail during the compilation on XCode with the error "Not authorized to send Apple Events to System Events. (error -1743).


on applicationWillFinishLaunching_(aNotification)
     tell application "System Events"
          -- any fragment of code that comes to mind
          tell appearance preferences
               set dark mode to not dark mode
          end tell
     end tell
end applicationWillFinishLaunching_


I have searched in google but I have not found anything,

thanks for help

Accepted Reply

macOS 10.14 introduces user approval for Apple events as well. You can learn about this in WWDC 2018 Session 702 Your Apps and the Future of macOS Security. However, that session misses one crucial detail: If you app is linked with the 10.14 SDK then you must include the

NSAppleEventsUsageDescription
privacy string in your
Info.plist
. Without this any attempt to send an Apple event will be denied with an authorisation error.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

macOS 10.14 introduces user approval for Apple events as well. You can learn about this in WWDC 2018 Session 702 Your Apps and the Future of macOS Security. However, that session misses one crucial detail: If you app is linked with the 10.14 SDK then you must include the

NSAppleEventsUsageDescription
privacy string in your
Info.plist
. Without this any attempt to send an Apple event will be denied with an authorisation error.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you eskimo, I was desperate.


Do you know how I can correct the warning, "Unable to load Info.plist exception (eGPUOverride)" ? Because it seems obvious that if I load the file, but exception. I've read many posts about that, but they do not convince me

Do you know how I can correct the warning, "Unable to load Info.plist exception (eGPUOverride)" ?

I’ve not seen that before but I’m willing to take a quick look. When does this show up? At build time? Or when you launch your app?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Running phase, any code

thanks!

Running phase

OK. I did a quick search and I wasn’t able to find any info on that. If you want a definitive answer I recommend you open a DTS tech support incident and talk to one of our graphics experts (which I am most definitely not)-:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks for all eskimo

Hello all, i know this thread is 3 years old, but i run into the same problem, and was not able to fix this. I red the thread really carfully... and i investigated some days only for this issue.. now i go to ask and hope to receive a hint. To be more exact: i have got some AppleScripts which control another application (ALS Page Director). The applescripts work fine under macOS 10.13. The same scripts and the same Application (same Version) doesn't work together under macOS 10.14. All script commands which are related to the OS work, when they are not in the "block "tell application 'ALS..'. (open files extracting content and so on, but when i try to reach the target application i receive everytime the Error 1743 (Not authorized to send Apple events...) To reproduce the behavior now i reduced the script into:

-- This section works
set theDialogText to "Outside of tell ALS"
display dialog theDialogText


tell application "Page Director ALS"
	-- This section fails....
	set theDialogText to "Called in ALS"
	display dialog theDialogText
end tell

During all the tests i recognized the following behavior:

  • When i start the script in the Script Editor then it works.
  • When i start the script in the Operating system environment (double click to the script or selecting from the menubar) then it doesn't run. I receive the mentioned error
  • When i start the script in the Script Debugger (another Application) it doesn't work, i receive the mentioned error.

The change I mentioned above applies to scripts as well as apps. Script Editor itself has special privileges, which explains why you’re not seeing the problem there. If you save the script as an applet, then the script runs in its own application context and thus has to meet the privacy requirements imposed by this change.

The menu bar case is interesting. Is this using the standard Script menu, the one you enable in Script Editor > Preferences > General? Scripts running in that environment should prompt for automation access, and there should be a record of those prompts in System Preferences > Security & Privacy > Privacy > Automation > Script Menu. Indeed, looking at that on my system I see entries for BBEdit, Sytem Preferences, Finder, Safari, and so on, all apps that my scripts automate.

Share and Enjoy

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

Hi eskimo, thank you very much for your information. It helps to receive a more clear picture about all this topic, but at the end my problem is still here... So i can explain what i made:

  1. i created a Developper ID certificate.
  2. i exported the script as an application and signed it with the certificate
  3. i made the whole notarization process like describe in (https://stackoverflow.com/questions/69354021/how-do-i-go-about-code-signing-a-macos-application) and it worked without any error.

But after that i receive still the same error. "Error 1743 (Not authorized to send Apple events...)"

After that i found another developer (from ALS Page Director) and he took the script and signed it with his certificate. the resulting application works. when launching it requests the authorization to control the other application. after allowing this it works.

This is now for me confusing. But this is not the end of the whole confusion: When i try to export the script by another machine (also 10.14.6!!!) then i'm not able to sign the application. i cannot select the installed certificate...

And at last to mention when i installed the script (as a script) in the menu you wrote above (Script Editor > Preferences > General) it doesnt work and in the Preferences > Security & Privacy > Privacy > Automation > Script Menu i have only the following picture:

This all is really confusing. i have the evidence that it is possible but but on my system I am stuck on all paths.

If you have an idea, you can't imagine how happy i would be.

Hello

After verify the certificate and notarise the application i run still into the same error:

Are there any ideas what the reason could be? i don't have any idea about this behavior