News
6th August 2015 | By:

Mac Installer adding app to the dock

Installing applications on Mac is a very simple task, all you have to do is drag and drop your application in a special folder named “Applications”, this tutorial will help you to create an installer for your application and the automation of adding to the dock. Adding to the dock is a post install process and requires you running a special script which adds your program to the dock.

There are number of tools on Mac which allow the creation of installers, most of them also to run post/pre install scripts, these are:

  1. Packages
  2. PackageMaker
  3. IceBerg

The following tutorial will use the Packages tool, the main reason being for it’s simplicity. The full tutorial and how to use ‘Packages’ can be found here, we are only interested in the post script section for this tutorial.

Once you have your application packaged and it is ready to be deployed we now need to configure “Packages” to run the post script which will setup the application in the dock, the tool we use is called Emmet[3]. Emmet is a simple application with a sole purpose of adding your application to the dock.

You can use Emmet #from command line with the following format

./emmett add path_to_our/project.app

Now we need to add the application to the ‘Packages’ project. Let’s use ‘Google Chrome’ as our application as an example.

Screen Shot 2015-08-06 at 08.49.44

Next set up a post installation script. After the installation the location of newly installed app is sent to the script as an argument so even if the user will choose different location than standard one, it won’t cause any problems.[1]

#!/bin/sh

# We only install the application in the Dock for the current user and when the installation is not run from the command line.
if [ "$COMMAND_LINE_INSTALL" = "" ]; then
    /usr/bin/su $USER -c "./emmett add \"$2\""
fi
exit 0

Now let’s select the app (Google Chrome in our case) and setup a post install script for it, see the picture below:
Screen Shot 2015-08-06 at 08.52.15

The final step is to include the small executable to the project without forcing user to install it.
Screen Shot 2015-08-06 at 08.55.48

That’s it. At this stage you can go a head and built the installer. Now you have a Mac application installer which will setup our application in the dock bar for each user.

References:
[1] http://s.sudre.free.fr/Software/Packages/Q&A_2.html

Resources:
[2] Packages
[3] Emmet
[4] post_install_script.sh

Tags: , , , ,

Leave a reply

Your email address will not be published. Not now, not ever. Required fields are marked *

Comments


You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Name
Email
Website