Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Xcode sandboxing: how to allow Documents folder access?

How do I gain access to the Documents folder? Under targets, "signing and capabilities", App Sandbox, I can see the Music folder, Desktop... but not Documents.

Answered by galad87 in 839497022

Show an NSOpenPanel, and ask the user to open the Documents folder, then store the security scoped bookmark.

Anyway, please don't litter the Documents folder with unwanted things.

Show an NSOpenPanel, and ask the user to open the Documents folder, then store the security scoped bookmark.

Anyway, please don't litter the Documents folder with unwanted things.

Keep in mind that, even if you’re app wasn’t sandboxed, you’d still bump into limitations access the Documents folder. See the discussion of MAC in On File System Permissions.

But, yeah, as galad87 said, the best way to access the Documents folder is via a document that the user selects in the open panel. If that’s not appropriate for your user case, please provide more details about what you’re trying to do.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Xcode sandboxing: how to allow Documents folder access?
 
 
Q