How to package an app with sqlite3 database I'm a new Mac user trying to create a *.pkg file which should hold an *.app (let's call it MyApp) and a corresponding sqlite3 database(let's call it MyAppDB.sqlite3). This application has been written in Python and transformed into a Mac application using Pyinstaller . It is hence not a 'native' Mac app. 

The *.pkg instalation process should copy the MyApp.app into ~/Applications/MyApp and the related database into ~/Library/Application Support/MyApp/MyAppDB.sqlite3

For this purpose I've used Packages, however the program seems no to copy the db into the ~/Library/Application Support/ folder since no new folders or files are created there after the installation process, only the ~/Applications/MyApp folder is correctly created where the app gets copied.

Without the database the program crashes. I've added a bash script which creates in a post-installation manner the missing folders into ~/Library/Application Support/MyApp/ and copies there the MyAppDB.sqlite3 file. Unfortunately the file has only read persmissions and I cannot change that. 

Hence my question: 


any expierience with Packages and how to sucessfully add files to other folder 
than ~/Applications ? Maybe I'm doing something wrong... ? 


Many thanks in advance for your help!
Check the Installer Log

Have you checked the Installer log file, /var/log/install.log, for errors or problems? Maybe the package is working but not installing where you expect.

A Better Approach

As Mark comments in your other question, try to avoid needing to install files in multiple locations.

Apple's developer tools for creating packages are:


pkgbuild
productbuild


Quick Fix using pkgbuild

Try the following approach for a quick fix. Note this installs to /Applications and not ~/Applications:


Prepare the files for packaging:

~/installer/
~/installer/Applications/
~/installer/Applications/YourApp.app
~/installer/Library/
~/installer/Library/Application Support/
~/installer/Library/Application Support/YourApp/
~/installer/Library/Application Support/YourApp/MyAppDB.sqlite3

Create the package with pkgbuild using a command like:

pkgbuild --root ~/installer/ --install-location / ~/Desktop/MyApp.pkg



Avoid this approach! Why?

This approach is not recommended because the install-location is root /. A robust installer will never install directly to root.

Problems include, what if the package's Applications, Library, or Application Support permissions differ from the user's permissions or ownership? What happens if the user has symlinked one or more of these files?

Instead a distribution package containing two standard packages should be used. One standard package will have an install-location of /Applications and the other with /Library/Application Support. This approach tells the installer tool to handle all the ownership, permissions, and symlink problems for you.

Ideal Approach

Ideally, a Mac application will be distributed as a self contained application bundle. If the MyAppDB.sqlite3 needs to be modified, a well behaved Mac application should copy a default database file from within the application bundle to the appropriate Application Support folder and use the copy as needed.

Be aware that if your application is sandboxed, the Application Support folder at /Library/Application Support/ will not be visible to the application. The application will be given its own, contained, support folder. This means that installing a database to /Library/Application Support/ will not behave as you expect.

If you can bundle everything in to the application, then a single call to productbuild will create a safe ready-to-distribute outside the Mac App Store installer package. Better yet, you could avoid an installer package entirely and distribute via a disk image or zip file.