Sandbox access issue

In a file saved by my App, there is a path to a file which could be in the user’s documents folder.
This works fine when not sandboxed, but files do not open when referenced from a Sandboxed version of the App.
Then trying to open the referenced file residing in Documents returns as NIL.
Is there any way to overcome this?

Which could be? What does that mean?

If it’s a resource that should be bundled inside your app there are different steps you need to be taking.
If it’s a document that your user saved, they provide your app access to the file when you use an OpenDialog.

The only situation I can think of where this might possibly be appropriate is if the item outside your sandbox permissions is an asset to a save file. Like an asset in an InDesign project, or the way the IDE handles images you drop in for a text project.

Before anyone suggests Security Scoped Bookmarks, keep in mind we don’t know the context of why the document might be outside the sandbox permissions. We can’t know whether SSB would work in this situation until we do (one needs access to the file before they can make a SSB to it).

Let me clarify: the user loads several files, the path to which is stored when the user saves from the app.
Then when reloading the saved file, I would like to re-access the files that were added by the user and saved as a reference.
So the files the user loads are assets to the file they save from the App, if that makes any sense.

Is the only way to include all loaded files ( which the user chose using dialogs) to save them all completely in a single file?

Or to maybe explain what I mean in another way; I want to do something like indesign does when you save an Indesign document; it doesn’t save the actual images placed in the documents, but merely a path reference to it, which it tries to load again when the user loads the saved indesign document.

Thank you for clarifying!

Since the user selects the files in the first place, you should be able to create Security Scoped Bookmarks to them. Security Scoped Bookmarks are outside the range of what I can give you detailed help with off the top of my head, so maybe @Sam Rowlands or @Christian Schmitz (who has a plugin for CFBookmarks) can offer some help.

Taking the InDesign approach makes it easy for designers to link to files that artists update, but unless you really need that “latest version” functionality I personally wouldn’t attempt it. The headaches involved with Security Scoped Bookmarks do not seem like they’re worth the time to me. My personal recommendation in this situation would be to copy the files into the save-document which would create one single file as you mentioned.

I wish you the best of luck, but unfortunately this has been all the help I can offer with this issue :frowning:

Reference material you might find helpful:
MBS Plugin Reference Page
Forum: A long thread in which they figure out and get SSBs working
Forum: Sam, the master of Mac, Tips on SSBs

Thanks Tim. I think I will indeed create a single file the user saves containing all files needed. Easier and avoids files missing issues too.

I have found that the best thing to do on the macOS is to use “Document Bundles” (folders with the correct UTI specification), and store all the resources within that folder. You can use macOS Hard Linking so that the file appears in both places (and your application has access), but it’s still only one file on disk.

Although the down side is that this only works on a Mac. If you want x-plat, take a look at Virtual Volumes, they’re a bit awkward, but might help here.