6th August 2015 by aegeuana_sjp_admin

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
[code language=”bash”]
./emmett add path_to_our/
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]
[code language=”bash”]
# 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""
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.
[2] Packages
[3] Emmet

Leave a Reply

Your email address will not be published. Required fields are marked *