1 year ago
#312237
Ninakadin
macOS app no longer can compose e-mail via AppleScript if sandboxed
I have a macOS app with hardened runtime (with enabled "AppleEvents") that uses AppleScript to create a preconfigured email addressed to us. Works like a charm. Since we want to distribute via App Store, I had to sandbox the app. So I added the sandbox option, and added these entries to Info.plist:
<key>com.apple.security.automation.apple-events</key>
<array>
<string>com.apple.Mail</string>
</array>
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.mail</key>
<array>
<string>com.apple.mail.compose</string>
</array>
</dict>
And I have an entry for:
Privacy - AppleEvents Sending Usage Description
That's what all the documentation I could find on the web says. When I send the script via NSAppleScript.executeAndReturnError
as result I get the following error dictionary:
<NSDictionary>:
<NSAppleScriptErrorAppName> = Mail
<NSAppleScriptErrorBriefMessage> = Application isn’t running.
<NSAppleScriptErrorMessage> = Mail got an error: Application isn’t running.
<NSAppleScriptErrorNumber> = <NSNumber> -600
<NSAppleScriptErrorRange> = NSRange: {635, 97}
For test purposes I stripped the AppleScript code to generate a very simple email without attachments etc. But I still get the same error. I can also successfully execute the script in Scripteditor.
As soon as I remove the "sandboxing", the email gets composed again. I am happy about any ideas.
applescript
appstore-sandbox
entitlements
appleevents
0 Answers
Your Answer