views:

98

answers:

4

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?

+2  A: 

OS 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).

Adam Wright
There **is** a centralized registry.
Yuji
Not that refers to actual "installed" applications. For example, the SPApplications set in system_profiler will contain e.g. iPhone applications you've developed, which can't really be considered an OS X installed application.
Adam Wright
A: 

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)

nolim1t
+2  A: 

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

Paul R
+1 solid answer (also see http://stackoverflow.com/questions/2518610/how-do-i-go-about-listing-all-of-the-installed-packages-and-versions-on-mac-os-x/2518684#2518684)
ChristopheD
To make it easier to parse the results in code, you can use the `-xml` flag to `system_profiler` to get property list output.
Nicholas Riley
@Nicholas - good point - makes life a lot easier
Paul R
+3  A: 

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,

Yuji