logoalt Hacker News

dcrazy • today at 2:59 AM • 1 reply • view on HN

That’s not quite how macOS sandboxing works. Users expect to be able to save and open (non-iCloud Drive) files in ~/Documents, not in a containerized silo. If the app uses NSOpenPanel/NSSavePanel, those work with the system to grant the app a sandbox extension to the location the user chooses in the open or save panel.


Replies

comex • today at 5:52 AM

Yes. Sandboxed apps do get their own home directories (~/Library/Containers/.../Data) and this home directory does contain a Documents directory, but this is just for compatibility's sake – there is no reason to actually use it for anything. Files that an app saves by itself are typically expected to be stored under Library/Application Support or Library/Caches, and this is still true even for a sandboxed home directory. Documents is reserved for files the user saves manually, but as mentioned, manually-saved files should reach the real ~/Documents.

Though, there is also a third type of Documents directory, the kind located at paths such as ~/Library/Mobile Documents/com~apple~TextEdit/Documents. This is part of iCloud Drive and is the same directory that you get in Finder by going to iCloud Drive -> TextEdit. Very confusing.