Closed CanisLupus closed 5 years ago
I'm not sure but it's probably because of apple's app sandbox. I think you have to specify file-access permissions in the entitlement key. Documentation is here.
You were spot-on, thank you very much. :)
Turns out that OpenFilePanel was working because we already had the com.apple.security.files.user-selected.read-only permission, since by following Unity's instructions we copied the entitlements file created by Xcode for a default project.
Adding com.apple.security.files.user-selected.read-write worked perfectly.
For reference, if anyone stumbles upon this thread, the correct entitlements file for us was:
<?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-only</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
Thanks again! Your help is much appreciated. ;) Daniel
Sorry to bother you again, Gökhan.
The following code crashes the plugin on a macOS build for the Mac App Store (i.e. built with Mac App Store Validation enabled in Unity, then codesigned and packaged, then installed from the package):
The crash results in the following in Unity's Player.log file:
The crucial part seems to be "service com.apple.appkit.xpc.openAndSavePanelService failed to init an instance of NSSavePanelService".
The error affects only the plugin (the app itself does not crash), which returns an empty path without opening the save file dialog at all. This does not happen on a standalone macOS build from Unity (i.e. not prepared for the store), which is very strange. StandaloneFileBrowser.OpenFilePanel seems to work regardless of SaveFilePanel not working. Could this be a permissions issue that doesn't happen for non-store builds?
It happens on both a recent iMac with Mojave (the error above is from that) and a very old MacBook Pro from 2010 with High Sierra 10.13.6. We are using the current unitypackage from your repository's "Package" folder.
Any ideas? :)
Cheers! Daniel Lobo