Accessing linked files when sandboxed

The app I'm working on has a document format that allows references to other, external documents/images/etc that are not necessarily stored adjacent to the actual document file, nor bundled alongside it.


I understand that the recommendation here would be to use document-scoped security bookmarks for each file (and then store that bookmark so that I don't have to ask again), but this is going to be a really invasive experience for the user to have to individually approve access to each of these linked files.


Is there any approach I can take here that would let the user review a list of these files for approval, rather than doing it one-by-one?

Replies

The user is going to have to specify those files. the only way to do that, at least in the sandbox, is via open panel and security-scoped bookmark.


However, that is how you initially access the files. My suggestion would be to immediately copy the files into the app's private document folder, inside a uniquely named folder for good measure. All systems run APFS now, so the copy is free. The user can then delete, move, change the original with no harm to your version.

One thing you can do here is survey all the paths involved, determine the deepest directory that encloses all of them, and then request access to that directory via an open panel. Access to that directory gives you access to all the enclosed items, at which point you can save the necessary bookmarks to retain access to those items.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Thanks for the suggestions, folks!

@John+Daniel, unfortunately I need to leave the files where they are. Part of the appeal of this app is that it will work with external resources without having to move them around, but that's a solid suggestion under different circumstances.

@eskimo I may end up having to do this, thanks for the suggestion about authorising a common parent. Not sure how that would play out in the user's experience, mind you ("why does this app need to access my entire home directory?!").

I think I need to file some feedback asking for enhancements to the user experience here — perhaps if the files I wanted to create security scoped bookmarks for could be collated into a single, easily reviewable dialog somehow that would be a much better experience, ie: I'm only asking the end user for access to what I actually need, and the user isn't bombarded with a bunch of same-same dialogs asking for access to each individual file (which would consequently cause the Vista effect and they'll just click through them without checking).