Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to zip Mac app that preserve all the properties

Tags:

java

macos

zip

ant

I have created one app at Mac using JavaFX. I am using ant to build and zip that app into a folder.

On trying zipping using

<zip destfile="MyApp.zip" basedir="MyApp"/>

It creating zip file but not preserving Properties of JavaAppLauncher which is found at MyApp/Contents.MacOS/

Then I have tried this command -

<exec executable="zip" dir="${basedir}/target">
  <arg value="-r" />
  <arg value="My-app.zip" />
  <arg value="My.app" />
</exec>

On unzipping this zip I found that this app also not launching. Now JavaAppLauncher's property is preserved, but this time I am facing issue of not preserving properties of libjli.dylib (which is an alias) found at MyApp.app/Contents/PlugIns/jdk1.7.0_21.jdk/Contents/MacOS, zip converting it to Dynamic Library.

Might be there are some more files which are failed to preserve their properties on zip. So how to preserve all the properties of libs, unix files, alias etc added inside app, so that I can successfully launch it after unzipping.

Thanks

like image 447
Neelam Sharma Avatar asked Nov 17 '25 00:11

Neelam Sharma


1 Answers

On my system at least, libjli.dylib is a Unix-style symbolic link rather than a Mac "alias", in which case you should be able to add the -y option to the zip command to preserve symlinks

<exec executable="zip" dir="${basedir}/target">
  <arg value="-r" />
  <arg value="-y" />
  <arg value="My-app.zip" />
  <arg value="My.app" />
</exec>

If it is an alias in the mac sense rather than a symlink then you could try using ditto, which can build zips that preserve the resource forks and hfs metadata in the same __MACOSX form that Finder's "create archive" option uses. In order to extract such a zip correctly users must double click it in the Finder (or extract it with ditto) rather than using unzip.

<exec executable="ditto" dir="${basedir}/target">
  <arg value="-c" />
  <arg value="-k" />
  <arg value="--keepParent" />
  <arg value="--sequesterRsrc" />
  <arg value="My.app" />
  <arg value="My-app.zip" />
</exec>

Or, as demure suggests in the comments, create a compressed disk image instead, which is the normal way Mac users expect their apps to be distributed

<exec executable="hdiutil">
  <arg value="create" />
  <arg value="-srcfolder" />
  <arg file="${basedir}/target" />
  <arg value="-volname" />
  <arg value="My App" />
  <arg file="MyApp.dmg" />
</exec>

This will pack the whole contents of target into the image, so you may need to change some of your paths a bit so that My.app is the only thing in the srcfolder (e.g. create it at target/appbundle/My.app and then pass target/appbundle as the -srcfolder to hdiutil).

like image 67
Ian Roberts Avatar answered Nov 19 '25 13:11

Ian Roberts