Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What location do OSX/Cocoa applications generally use to store data files?

Do they write/store them within the app bundle/package itself? Or some other canonical location? Or does there not seem to be any standard?

like image 334
anthony Avatar asked Jan 06 '10 22:01

anthony


4 Answers

Files usually go in ~/Library/Application Support/Your App/. Preferences go in ~/Library/Preferences/.

like image 186
Chris Long Avatar answered Oct 17 '22 10:10

Chris Long


NEVER modify a file inside your own app bundle.

like image 25
Nicolás Avatar answered Oct 17 '22 09:10

Nicolás


You should decidedly not write files into your app bundle at runtime. There's no guarantee that a user running your app will have permission to modify it. As Chris said, support files go in Application Support and preferences go in ~/Library/Preferences. To find the user's Application Support folder, you can use the NSSearchPathForDirectoriesInDomains() function. To write preference files, you can use the NSUserDefaults or CFPreferences APIs.

like image 4
Chuck Avatar answered Oct 17 '22 11:10

Chuck


Mac app data is now stored in ~/Library/Containers/YOUR-APP.

like image 1
samwize Avatar answered Oct 17 '22 10:10

samwize