Creating a Mac OS X application package (from a mono project)

I’ve recently been asked to work on a little project and I was free to use the technology I saw fit. Given that the project had to be multi-platform and provide a complex GUI, I decided to go with C# (using Mono) and Gtk#. It’s choice I find to be pragmatic and practical for this particular set of demands.

I work on the project with MonoDevelop (or Xamarin studio (or whatever you’re supposed to call that monstrosity that passes as an IDE now)) mostly because it makes working on Linux and Mac OS X a breeze. As you can imaging, C# and Windows go well together too.

While discussing the technological aspect of the project with a colleague, the subject of Mac application packages came up. You know, these .app files. I decided to look into that for a bit.

I already knew that these “files” were in fact directories with a specific folder structure and an xml file pointing to the various resources and executables needed for the program to work. I didn’t delve too deep into the manual creation of these packages, but I knew enough to have a sense of what I was looking for.

Packaging the application

It turns out the standard mono distribution offers a command line utility designed for this exact purpose. While I didn’t create a MonoMac project, I was able to package my GUI application relying on Gtk# rather effectively.

This command line utility called macpack is extremely simple to use, just point him to the direction of the files you want to package, specify the name of the assembly containing the Main method and you’re good to go.

macpack [options] assembly
    -n appname  -appname:appname    Application Name
    -o output   -output:OUTPUT      Output directory
    -a assembly                     Assembly to pack
    -i file     -icon file          Icon filename
    -r resource1,resource2          Additional files to bundle
    -m [winforms|cocoa|x11|console] The mode for the applicatio

This is the line I used to compile a little test project:

macpack -o:. -w:winforms -r:/Library/Frameworks/Mono.framework/Versions/Current/lib/ -r:GtkMacTest.exe.mdb -n:GtkMacTest -a:GtkMacTest.exe

The -w:winforms was a bit of a shot in the dark as there is now Gtk specific option… in the end it worked out well.

I didn’t experiment with the -i option, so the resulting package looks rather ugly with the default icon on, but I’ll look into that another day. For now, all that matters is that I created a working .app to distribute the project.

Other methods (?)

While looking for informations on how to easily create Mac .app packages, I stumbled about a project called Platypus. While I don’t have any use for it now, it may be a good idea to experiment with it at some point. Not all projects can be made with Mono and the convenient tools it provides.



Enter your desired user name/password and after your comment has been reviewed by an admin it will be posted and your account will be enabled. If you are already registered please login before posting.