Not authorized to send Apple events to Contacts. (error -1743)

I have AppleScript code that extracts name and address data from an entry in Contacts which works when running under Script Debugger. But when I include this code into an ApplescriptObjC project in Xcode it fails with the “Not authorised” error.
When I check the apps allowed to access Contacts in Security & Privacy the ApplescriptObjC project is not listed but cannot add to this list.
Not sure where to go from here so any help gratefully received!

When you execute the command you should get a query from the OS asking if you want to allow your application to have access to Contacts. It might be that since you’re calling it from within Xcode that it’s not working. Have you saved your project as an app and tried from the app?

ALSO … The best place to get answers to questions related to ScriptDebugger and AppleScriptObjC is the ScriptDebugger forums

https://forum.latenightsw.com

While most of the experts there (Shane, Nigel, Mark) are also here, they seem to respond faster there. Since you’re using ScriptDebugger, you’ll see Script Debugger Forums as a selection in the Help menu.

When you ask your question, it’s very helpful if you provide your MacOS system and ScriptDebugger versions. Like this:

→ Script Debugger 8.0.4 (8A52)
→ Mac OS 11.6.5 (20G527)

Might also help to provide the Xcode version too.

Thanks for your reply and I’m sorry for not making it clear that Xcode is issuing the error message. I only mentioned Script Debugger because the Contacts code works perfectly with that. This is an existing ApplescriptObjC project that prints a document using name/address data extracted from various sources (email, user input) so wanted to add data from Contacts.
Have tried running the project as an app but no response when selecting the Contacts option.
I am using Xcode 12.5.1 running under Mac OS 11.6.5

Model: MacBook Pro
Browser: Safari 605.1.15
Operating System: macOS 11

It sounds like you need to add an NSContactsUsageDescription string to your app’s Info.plist file. You can do it in Xcode under the Info tab.

Thanks, all working now