Best location for database file in Mac OSX


Best location for database file in Mac OSX



I'm working on an installer for an application that I have ported to OSX, but I don't have much experience with this OS so I want to know where is the most appropriate location to install a database file that will be used by my app.

The database file is relatively small, and will be updated by a daemon process but must be accessible to all users on the system via a command-line tool. On Linux I have used /var/lib/myapp/mydata.db, what would be the OSX equivalent?




Inspect contents of a basic, unencrypted UDIF DMG file

1:



How can display driver version be obtained on the Mac?
There are two approaches on OS X:.
Programatically get/set Mac OSX default system keyboard shortcut
  1. OS X defines application and user-level "application support" folders.


    Right click or two finger tap [closed]
    These are in /Library/Application Support for system-wide and in ~/Library/Application Support/ for user-level support files.


    Mac PGP WDE emergency recovery procedures
    Application support folders are supposed to be named by the app's bundle identifier (e.g.


    What's a good hex editor/viewer for the Mac? [closed]
    com.company.app), but many just use the application name.


    Why does the Mac ABI require 16-byte stack alignment for x86-32?
    In general, OS X uses this pattern (system-level in /Library and user-level in ~/Library for application support, preferences, plugins, etc.).


    Creating a new webproject with MonoDevelop 2.1 under Mac OS X => exception
    /Library is, by default read-only for non-administrator users.

    If your command line tool is run as root (or via sudo), then you could put your database file in /Library/Application Support/your-app.

    Of course, since you'll need to do this in an installer script (either traditional unix style or via an OS X installation package), you could modify the read-write permissions of your db file..
  2. As others have pointed out, OS X is a UNIX OS, so you can create /var/lib or any other folder to your liking.

    Many UNIX ports do this as it keeps things more consistent with other OSes that they support.

    If you do this, make sure to provide an unistaller script that removes the folders you add (assuming nothing else has been added to them by other apps/users/etc.!).

    Mac users generally frown on installers throwing crap all over the file system without an easy way to clean it up.

    Also, MacPorts, and Fink (two OSS package managers for OS X) use the /opt and /sw trees respectively.

    You probably don't want to mess with those trees as it could cause problems for users of these package managers.

    Of course, one of the best ways to go if you want to keep things UNIX-y is to package your app for MacPorts or Fink.

    MacPorts is of the BSD ports tree lineage and Fink is of the debian lineage.

    MacPorts is the Apple-sanctioned package manager, but both seem popular..


2:


Macintosh HD/Library/Application Support/Your App/data.db would probably be the place..



72 out of 100 based on 52 user ratings 402 reviews