1

How to check the location of an application installed under OS X? I tried it with the method LSFindApplicationForInfo and it works fine if you are searching for the bundle identifier.

But this way is not working if you have installed more than one instances of an app. LSFindApplicationForInfo just gets the location of one instance of an app. Furthermore this function is deprecated in OS X 10.10.

The terminal input mdfind "kMDItemCFBundleIdentifier from the following thread works fine, but it just works if spotlight is enabled.

How to get the locations off all app instances with the same bundle identifier or the same name "name.app" inside source code written in C or Objective-C?

How to find multiple apps with same bundle identifier?

Check if a Mac OS X application is present

Community
  • 1
  • 1
3ef9g
  • 781
  • 2
  • 9
  • 19
  • Are you looking for an app of your own, one whose properties you can control? Or are you asking about the general case? – Ken Thomases Feb 26 '15 at 18:59
  • I am developing an app which should check if another special app is present on the system. If yes, I need for each instance the complete system path of the special app. For example if an app is located on the desktop and at the same time inside the application folder (may as an older version) then I would like to know following paths: /Users/.../Desktop/name.app and also /Applications/name.app – 3ef9g Feb 27 '15 at 17:01

1 Answers1

3

If you can target 10.10 or later, you can use LSCopyApplicationURLsForBundleIdentifier(). This is documented as returning the URLs of all applications with the given bundle identifier.

It's not clear to me if the app you're attempt to find is one whose properties you control. If it is and you need to support versions of OS X prior to 10.10, one approach you can use is to make the target app claim to support a custom dummy URL scheme. Then you can use LSCopyApplicationURLsForURL() to find all instances of it. You construct a URL with your dummy scheme, such as com-yourcompany-yourproduct-app-identifier-scheme://junk and pass that as input.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • Unfortunately, I am here in 2023 and `LSCopyApplicationURLsForBundleIdentifier` is depracated. I have not found a replacement. – spartygw Apr 13 '23 at 19:04