Process::openEmailWithAttachments on Mac with Sandboxing entitlements

I’m posting an answer to a question no-one has asked in the hope it will save someone else the misery I went through. Under MacOS (and according to the doc iOS, but I haven’t tried this) the Process::openEmailWithAttachments requires specific entitlements to run if you have a sandboxed app. You can’t change this in the Projucer and I couldn’t find a way of doing this in Xcode. The solution I used was to add the following key to the App.entitlements file:

<key>com.apple.security.scripting-targets</key>
<dict>
    <key>com.apple.mail</key>
    <array>
        <string>com.apple.mail.compose</string>
    </array>
</dict>

This is documented by Apple here

1 Like