6

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?

1 Answer 1

4

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/
    
9
  • is there anything I have to do to install in /Applications ? Or is that the default place an app would get installed ? Would I use a package manager to specify the target location ?
    – Thalia
    Commented Oct 29, 2014 at 17:33
  • 1
    @Thalia The standard way a user installs an app in OS X is they download the .app bundle and use Finder to copy it to /Applications, then they open it to use it.
    – grg
    Commented Oct 29, 2014 at 17:35
  • 1
    @Thalia Technically, best practices say that it should be a .plist, but there's nothing stopping you using a text file or similar. If you really want to use a text file but also want to follow best practices, put your text file in a folder (in the Application Support folder). Apps in OS X are expected to prepare themselves: detect a missing database and download the resource from an external server.
    – grg
    Commented Oct 29, 2014 at 18:08
  • 1
    As an addendum, if you're creating the app, please do not assume that the app will live in /Applications or ~/Applications! Users may elect to keep or move certain apps elsewhere for organizational purposes. The app should work no matter where it lives, unless you have a very good reason to not allow this (in which case you'd still want to check the location and notify the user). Commented Oct 10, 2020 at 14:34
  • 2
    @Thalia Regarding the ini file, I'd include the default copy in the Resources folder inside the application bundle. When the app is launched, see if the ini file already exists in ~/Library/Preferences; if it does not, copy the default one from your app bundle into ~/Library/Preferences. Commented Oct 10, 2020 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .