OS X: package location by identifier for a newly installed application

A question similar to Finding packages by ID , but another problem:

I have several applications that need to find each other by their identifier. This always works well unless I make a completely new installation of all my applications. In many cases, it is enough to indicate to the search device the installation location for the location of the node to be known, but sometimes even this is not enough; I have to run the application before its package identifier can be used to find the path. I should mention that I use an installer that copies applications to / Applications /, so the crawler never opens when installing applications.

It seems that when the application package is recently installed, it takes a while for the system to update any internal registry that matches the package identifier at the package location. I would like to know the following:

  • where are these mappings stored and
  • how can I get the system / file manager / workspace (?) to update the map.
+4
source share
2 answers

Mappings are stored in the startup services database. I am not where it is stored, but the exact location does not matter, because there are better ways to achieve your goal.

You can manually update the startup services database in several ways, but personally, I think that doing this programmatically would be easier, especially in your situation. In this case, you would use the Launch Services API, in particular, I would consider using LSRegisterURL() , since that seems to be what you want to do.

See the Launch Documentation for more information on registering applications in the database and how it all works in general.

+2
source

An alternative, if you ever need to, is to search using the Spotlight API using kMDItemCFBundleIdentifier :

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

Spotlight is tightly integrated with the system, so files / folders are indexed, as soon as they are written to the file system, you should not have any problems with the fact that the application was not indexed. Of course, you should be prepared to process more than one answer ...

+3
source

Source: https://habr.com/ru/post/1286199/


All Articles