2
votes

Aim

Gain read access to files outside the app sandbox environment WITHOUT a user selecting the files directly.

The idea is that a user selects an fcpxml document (via NSOpenPanel) which is then parsed and all of the filepath strings are collected. I then create URL objects from the filepaths and read those the files at those URLs later.

Problem:

With App Sandboxing enabled I am unable to access(read) file URLs that I create using the URL method init(fileurlwithpath).

The Entitlement "com.apple.security.files.user-selected.read-write" seems to only give me access to the user-selected XML file and not the referenced files in the fcpxml document.

Can anyone recommend a way to be able to do this?

Cheers!

Adam

1
I forgot to mention the error I get is Error: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn’t be opened because you don’t have permission to view it."adamteale
"filepaths that are referenced inside this xml file" Which xml file?El Tomato

1 Answers

3
votes

You didn't specify details about the paths you are collecting. Are they relative to the XML document or are they always referring to files in a certain folder?
If it is guaranteed, that the paths you are collecting always point to a common System folder (e.g. "Movies" or "Music"), you can add an entitlement that allows you to gain read/write access to those folders.

If the files are scattered all over the file system, you could prompt your users to select a common root folder via NSOpenPanel and store an app-scoped Bookmark to persist access to the selected folder across app sessions.