macosinstallationinstall4jdmg

Update an app on mac using dmg without losing data


I wrote a program in Java that creates some files similar to this:

FileOutputStream fos = new FileOutputStream("data.txt");

...

I created a dmg-drag-and-drop-installer using install4j, which works perfectly.

When I deliver an update with a likewise installer, macOS allows to install the update parallel or as a replacement for the existing version. The formerly created "data.txt" will be deleted due to the replacement.

Is there any opportunity to change the update process so that like in windows only those files are changed, that exist in the update package? In windows I can run the installer of the newer version and the user data is not being touched.

Or will I have to store all the files for example in the documents folder to solve this issue?

Thank you for your help!


Solution

  • Or will I have to store all the files for example in the documents folder to solve this issue?

    Yes, you will have to do that. macOS replaces entire application bundles, it does not merge them.

    Writing inside the application bundle is also not a good idea, because it will break the signature.