Code and Stuff

Feb 24, 2012

Eclipse RCP Mac OS App Export Tricks

Exporting an Eclipse RCP application for Mac OS X produces a result that is not very Mac like:
  1. The user settings should be saved in the Library path.
  2. An application on Mac should be a single .app package. No other folders should be needed.

The user setting

Let me start with the simple one. What we actually want to do is to place the worspace inside the Library folder. This can be done in the eclipse product configuration by setting the following program launching argument for the MacOS:
-data
@user.home/Library/YourAppName
This will use ~/Library/YourAppName as the default location for the workspace.

Making the App

Unfortunately, AFAIK, Eclipse is not capable of generating the single App thing. There has been an open bug for quite a while now and there seems to be no interest to address this problem. In the mean time there is a quite simple solution.
  1. Export the product the usual way. You will end up with the folder containing the .app, plugins, etc.
  2. Open the folder containing the generated stuff with finder, right click the .app file and select "Show Package Contents".
  3. Move everything except the app itself into the "Contents/Resources" folder of the package.
  4. Open the .ini file in "Contents/MacOS" with a text editor and update the -startup and --launcher.library paths replacing ../../../ with ../Resources/

And that should be it.

This applies to eclipse 3.7.1 and was not tested extensively. Please see the comment of Scott Barrett if the app cannot find the library.

Eclipse.app

Since Eclipse RCP applications and the Eclipse IDE are based on the same technologies this tricks should apply also to the IDE.