Reputation: 101
I'm trying to execute simple AppleScript in Objective-C. The code is:
NSString *emailString = @"tell application \"Mail\" to activate";
NSAppleScript *emailScript = [[NSAppleScript alloc] initWithSource: emailString];
NSDictionary *errorDict = NULL;
[emailScript executeAndReturnError: &errorDict];
And got this annoying error:
NSAppleScriptErrorMessage: Mail got an error: Application isn’t running. NSAppleScriptErrorRange: NSRange: {27, 8} NSAppleScriptErrorBriefMessage: Application isn’t running. NSAppleScriptErrorNumber: -600 NSAppleScriptErrorAppName: Mail
It's no problem if I execute the script from Script Editor. I need some help — Thanks!
Upvotes: 3
Views: 627
Reputation: 101
Solved. My app using Sandbox. And if you want run AppleScript from it, you need edit entitlements file. In me case this help.
Upvotes: 6