MacOS – Folder locations for macOS app

applicationsfoldersmacos

I am porting an application from Windows and Linux to macOS.

The application is written in Qt. It has a few dependent dylib (some built, some sdk). The exact same libraries and same Qt version are used for some other applications (which are not ready to be ported yet). It will not be distributed through the App Store.

The application can read, write, drag-and-drop, print custom type user files. It uses a sqlite3 database, provided – users should be able to browse to its location (since they should also have the ability to use a database from a different location). During print, it would be best to use the cups temporary folder to save temporary bitmap files.

I have tried to figure out the best way to install this type of app. Is the bundle packaging right for this type of app, or should I use the file system to place all required files in the most likely locations?

  1. Creating a bundle so far, I have the dependencies (including Qt
    frameworks) inside the Contents/Frameworks directory.

    • Where would I place the user created files… inside the bundle or inside the Users/MyCompany/MyProgram directory? I tried to save inside… can't browse inside the MyApp.app from inside the program.
    • Where would I place the sqlite3 database? If I place it inside the bundle (e.g. Contents/Resources), I cannot access it from inside the program.
    • Where would the entire bundle be installed? in /Applications/MyCompany/MyProduct is my guess?
  2. Without a bundle: from what I read, the following may be good locations:

    • For the executable: /Applications as above?
    • For the dependent libs: usr/share/MyCompany/MyProduct or
      /Library/MyCompany/MyProduct ?
    • User files obviously
      Users/MyCompany/MyProgram
    • Resource database ? I have no idea what a
      good place is, accessible to all users, where to keep such a file
    • This setup would allow other applications to be installed and use the
      same Qt framework and dependent dylibs… But I read something about
      apps not working if the dylibs are modified ?

Which is the best way and in that case, which are the best folder locations?

Should I assume that the installation is made with sudo rights? Can the installation be done without admin rights?

Best Answer

The application bundle should go in /Applications. This application bundle should contain everything. Libraries, dependencies, everything that the app needs to run, so that should the application bundle be copied to another machine's /Applications directory, it should be able to run.

Installing in /Applications requires admin. Should admin not be available, the standard location for a single user application is ~/Applications. This directory should not be expected to exist.

If something needs to be 'installed' on the system for the app, such as the aforementioned 'resource database', the app should prompt to install it in:

/Library/Application Support/developername/appname/

Should something need to be 'installed' for the current user, it should go in the same path prefixed with their home directory. This doesn't require admin.

~/Library/Application Support/developername/appname/

User files should not be saved in the root of the user's home directory. The user should have the opportunity to save files wherever they please, preferably with a standard OS X save dialog.

Also…

  • Cache files should go in:

    ~/Library/Caches/developername/appname/
    
  • The users preferences should go in:

    ~/Library/Preferences/com.bundleidentifier.plist
    

    If something more than a single property list needs to be saved…

    ~/Library/Preferences/developername/appname/