Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sandbox path for OS X applications

Tags:

macos

sandbox

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?

like image 767
XiOS Avatar asked Mar 19 '23 07:03

XiOS


2 Answers

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.

like image 95
Droppy Avatar answered Mar 28 '23 14:03

Droppy


I believe it is the best to use NSHomeDirectory() to get the path.

like image 43
Ivan Ičin Avatar answered Mar 28 '23 14:03

Ivan Ičin