Hi, could you tell me please - which object and which method can i use to fetch information about installed applications on OSX with objective c or macruby?
views:
98answers:
4OS X doesn't really have a notion of "installing an app". OS X applications are self contained bundles that appear in the Finder as a single virtual file. There's no central registry, just a convention that applications are placed in /Applications or ~/Applications for a per user "install".
About the best you can do will be enumerate those directories for their contents, and every ".app" directory you find is an application. It will not be a exhaustive (I often run small apps from e.g. my Desktop if I've just downloaded them).
As it is a unix-like OS there is no real way of telling what you have installed (unless of course you have control of the other app - then there is a lot of ways of doing this for obvious reasons).
Generally apps get put into /Applications or ~/Applications BUT you can run it from anywhere and not those folders (just like a unix machine)
You can just call the Apple command-line tool system_profiler
, e.g.
% system_profiler SPApplicationsDataType
For C or Objective-C you could use system()
to do this.
For more info:
% man system
% man system_profiler
If you meant to list all of GUI apps, you can use Launch Services. For the list of functions, see the reference.
Do not manually list .app
bundles! It's already done by the system, and you just have to query it.
There is a command-line program called lsregister
at
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
which can be used to get the detailed dump of the Launch Service database. This tool is sometimes helpful, but don't depend on that in a shipping program,