OS X Sandboxed Standalone App - Save Preset Functionality & temp files

I am developing stand alone app but facing problems with sandboxed app in save preset functionality.

I have set correct entitlements for the project and user can properly select file location. However Juce Library File class tries to create temporary file (with other file name, but same directory) when saving the preset. This fails (because of the security restrictions). Writing is only allowed to the file name user has given on the save dialog (this is my assumption).

replaceDataWithData fails (juce_StandaloneFilterWindow.h::askUserToSaveState)

 if (! fc.getResult().replaceWithData (data.getData(), data.getSize()))
            AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
                                              TRANS("Error whilst saving"),
                                              TRANS("Couldn't write to the specified file!"));

Does anyone have a workaround for this?

I don’t know the answer to your question, but perhaps this thread can help?

In the sample code they seem to be: a) running the modal async and b) doing some tmp file juggling?

I would suggest writing the file entirely in the app bundle, and then, in the async lambda (which will have elevated permissions) moving it to the selected location.

1 Like