It's impossible for me to run an Apple Script from XCode. Here is how I try to make it work :
let appleScript = NSAppleScript(source: script)
var error: NSDictionary?
if let outputString = appleScript?.executeAndReturnError(&error).stringValue {
print(outputString)
} else if (error != nil) {
print("error: \(error!)")
}`
I got this error in output :
error : {
NSAppleScriptErrorAppName = Finder;
NSAppleScriptErrorBriefMessage = "Not authorized to send Apple events to Finder.";
NSAppleScriptErrorMessage = "Not authorized to send Apple events to Finder.";
NSAppleScriptErrorNumber = "-1743"
NSAppleScriptErrorRange = "NSRange: {63,1O}"
I've done everything described here and check every permission on my Entitlement file. "Apple Events" are set to "YES", but that is still not working.
I'm really stuck here. Any suggestion ? I'm on Monterey.