Mac OS App Sandbox - Can't Write File Without NSOpenPanel or NSSavePanel

105 Views Asked by At

I'm working on a Mac OS app and just ran into an interesting situation. As this is a file based app, users can drag and drop files and folders onto the app and they get added to an array and displayed in a list. They can also add files and folders via an NSOpenPanel.

When the file is added a lot of file variables get set, one of which is the save directory which is set to the same directory as the file.

Due to the App Sandbox, unless the user manually chooses a save directory (after the file has been added), even if it's the same directory that is already set for the file, I cannot write the export.

This app allows users to add a bunch of files and batch them all out at once, so requiring manual user interaction to set a save directory is cumbersome, especially if the user just wants to save out to the same directory as the original file they added.

I know I could request full disk access but I think that's very intrusive and there's really no reason this app needs that kind of permission. I don't want to be able to write anywhere, and I still want the user to be able to manually select a different save directory, but it would be helpful if they didn't have to manually select a save directory for every file, and the sandbox would allow the same directory as the original file to be written to.

So, long story short.....

I'm wondering if there is a solution to expanding the sandbox when a user adds a file, instead of only when they are saving the exported file?

0

There are 0 best solutions below