FileChooser browseForFileToSave vs Sandboxing App


I am having big trouble with an app for macOS Big Sur. I want to issue that app to the App Store, therefore, I have to enable sandboxing. But that breaks the save functionality: I want to save a text file to a location selected by the user. Therefore, I call chooser.browseForFileToSave(true), the file dialog pops up I can enter a file name but when I do this:
File fileSave(chooser.getResult().getFullPathName());
TemporaryFile tempFile(fileSave);
FileOutputStream output(tempFile.getFile());
I get an “Operation not permitted” error from output.getStatus().getErrorMessage()
It is clearly caused by the sandboxing. If I turn it off it works perfectly.
I tried already to change entitlements and added: = true = true = true
But nothing solved it. If have spent two days with searching on the internet without success. The only hint I could find was something like use NSSavePanel. Harharhar, you would expect that the JUCE framework takes care of this… :wink: And actually I think it does, doesn’t it?
So any idea? Help would be really appreciated.


Found the solution myself: The TemporaryFile object makes Gatekeeper & Co very unhappy.
I have now removed it and init FileOutputStream directly with fileSave. Then it works!