-[NSWorkspace URLForApplicationWithBundleIdentifier:] returns apps from xcode archives

fyi, found this strange problem when trying to check if a different mac app is installed... from an ObjC mac app. see attached snapshot of debug.

it finds the app all right, but it's from an xcode archive rather than an installed runnable app.

does anybody know a workaround for this? i guess delete those archives temporarily...?

the deprecated method fullPathForApplication also does this, lol

Welcome to the world of wonders that is the Launch Services database (-:

This aspect of NSWorkspace is a thin wrapper around Launch Services. Launch Services has a database of known apps and one of those apps is the default, the version that gets launched when the user double clicks a document owned by the app. AFAIK, and your tests seems to confirm that, Launch Services doesn’t have any smarts to specifically exclude apps within an Xcode archive.

Now, you could argue that it should (and I’d probably agree with you on that front :-). Feel free to put your argument in a bug report about this. Please post your bug number, just for the record.

As to what you can do about this, it kinda depend. This isn’t an issue on most user machines because they don’t have an Xcode archive containing your app. So this problem is only affecting you (and maybe other developers on your team). The way I usually get around this is as follows:

  1. In the Finder, select a doc that’s opened by my app and choose File > Get Info.

  2. In the “Open with” pane, click on the popup and select a specific app to be the default.

  3. Click Change All.

Does that work for you? If not, please elaborate on the specific circumstances you’re dealing with.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This behavior has been around for years. Pretty sure I filed a bug on this years ago and they closed it as “works as intended” and basically told me to pound sand. I recall a related issue where if your app was set to “Launch at login” launch services would sometimes launch an app build in Xcode archives at login.

I think it’s possible to workaround the issue by unregistering the app with lsregister…I never tried. I manually zip my Xcode archives to avoid this issue..been doing it forever. Even if there is a workaround it’s absurd default behavior. Pretty sure Apple has known about it for a very long time.

-[NSWorkspace URLForApplicationWithBundleIdentifier:] returns apps from xcode archives
 
 
Q