Search code examples
macossandbox

Sandbox path for OS X applications


I would like to save my application's data in sandbox path where user don't have access to.

My application data could be in the form of a file or a directory.

What is the sandbox path for Mac applications? And how could I access this path?


Solution

  • You cannot hide data from the user, if that's your goal, as the app runs with the user's UID. The sandbox path is mapped to:

    ~/Library/Containers/app-bundle-id/Data/
    

    and is accessed from the sandboxed app using the NSSearchPathForDirectoriesInDomains() Foundation function, and the folder you get from this call depends on the NSSearchPathDirectory value you pass in. This site has many examples of its use.