I'm working on a Unity app that includes a native plugin to save images. Debug builds, so far, work fine – as does the code-signed build to test in-app purchases, but once I include sandbox entitlements, we're unable to save screenshots. This isn't entirely unexpected, as I haven't done much with app sandboxing before...
But when I attach the app to Xcode to step through the native plugin code, to see where it's breaking down, I see that where it's failing is in creating the NSSavePanel itself. [NSSavePanel savePanel] simply returns nil. No errors, no exceptions, nothing.
What exactly is going wrong? If it was an entitlements issue, I'd expect some error to be thrown. Since the part that handles the open/save panels is a framework, it itself doesn't have a Capabilities tab & I have to sign & add the entitlements from the command line.
If it was an entitlements issue, I'd expect some error to be thrown.
Indeed. I just tested using NSSavePanel without the proper entitlement and it throws a runtime exception.
But just to be sure, are you including the
com.apple.security.files.user-selected.read-write key in your entitlements file? A basic entitlements file would look like this:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>