Having spent a frustrating hour or so trying to update a mac application bundle I thought I’d share a couple of things which caused no end of confusion and aren’t what you’d expect and are therefore likely to catch out those working with application bundles for the first time.
Basically I was finding that although I was making changes to my bundle these changes weren’t actually being applied. The bundle seemed to hold on to older versions of the data in the bundle even if this had been changed or even deleted.
It turns out that OSX caches information from the application bundle and then doesn’t check to see if the information in the bundle has been updated unless it is forced to. There are two separate caches which can affect you, a cache of the bundle icons, and a cache of the Info.plist file.
Inside your application bundle you can create a file containing a series of icons for your application. You make this file from a series of individual bitmap files normally by using the icon composer application which comes with the developer tools in OSX. What you will find is that if you update your icns file containing your application icons you won’t actually see any difference in the icons which are shown in the finder. The reason for this is that OSX caches the icons associated with files in a folder in a hidden file called .DS_Store. If this file is present then the finder will read the icon data out of that even if the icns file in your application bundle has been updated.
If you want to force the finder to recalculate the DS_Store file then you need to do the following:
- Make sure you have closed all finder windows showing your folder of interest
- From within the terminal delete the .DS_Store file from your folder of interest
- Relaunch the finder using Apple > Force Quit > Finder > Relaunch (this won’t affect any of your running applications)
This will force the finder to recalculate the icon cache for your folder and any changes to your icns file will be visible.
The Info.plist file in your application bundle provides all of the basic information about how to launch your application, where to find the icon file and various settings relating to the applications name and version. As with the application icons the information in the Info.plist file is cached by the OS, such that if you change the data in the file (say you change the name of the executable you want to run), then the bundle will remember the old value not the new one.
As an aside, if you’re having problems running an application bundle, the easiest way to see what’s actually going wrong is to open the Applications > Utilities > Console application and then relaunch your application. Any output generated on stdout or stderr by an application bundle will show up in this application and you can see any error messages which are generated.
Clearing the Info.plist cache is a bit easier than clearing the icon cache. The quickest way to reset it is to simply move your application to a different folder (say your desktop), and then move it back. This will reset the Info.plist cache and your changes should be applied.