Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OS X: bundle location by identifier for newly installed application

A question similar to Locating bundles by identifier, but different problem:

I have several applications that need to locate each other's bundles by their ID. That always works well, unless I do a completely fresh install of all my applications. In many cases it's sufficient to point the finder to the install location for the bundle locations to be known, but sometimes even that's not enough; I have to run the application first before it's bundle ID can be used to find the path. I should mention that I am using an installer that copies the applications to the /Applications/, so the finder never opens when I install the apps.

It appears that when an application bundle is newly installed, it takes the system some time before some internal registry is updated that maps the bundle ID to the bundle location. What I would like to know is:

  1. where are these mappings maintained and
  2. how can I force the system/file manager/workspace (?) to update the map
like image 395
Thomas Jung Avatar asked Jun 14 '09 17:06

Thomas Jung


2 Answers

The mappings are maintained in the Launch Services database. I don't where this is stored, but the exact location is irrelevant, as there are better ways of achieving your goal.

You can manually update the Launch Services database in a number of ways, but personally, I think doing it programmatically would be easier, especially in your situation. In that case, you would utilize the Launch Services API—specifically, I'd look into using LSRegisterURL(), since that seems to achieve what you want to do.

Take a look at the Launch Services documentation for more information about registering applications in the database and how this all works in general.

like image 170
hbw Avatar answered Sep 24 '22 01:09

hbw


An alternative, in case you ever need one, would be to search using the Spotlight APIs with the kMDItemCFBundleIdentifier key:

pierre$39> mdfind "kMDItemCFBundleIdentifier == 'org.videolan.vlc'"
/Applications/VLC.app
/Applications/vlc-0.8.6c/VLC.app

Spotlight is tightly integrated with the system, such that files/folders get indexed as soon as they are written to the filesystem, you should not have any issue of the app not having been indexed yet. Of course, you have to be ready to handle more than one response…

like image 32
Pierre Lebeaupin Avatar answered Sep 25 '22 01:09

Pierre Lebeaupin