Launchctl command line equivalent of “absolutePathForAppBundleWithIdentifier(”com.bundle.helper")

On OS X, I'm looking for a command line which would show the known path of a bundleIdentifier from Launch Services point of view.


If there're several bundles with same id, my app keep looking for a trashed one, or copied, and it's hard to troubleshoot without a command like "launchctl .... mybundleId"


In swift, I've found: let launchdPathToHelper = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(bundleIdHelper)

This helps me and gives me the answer, but sure there's a command line for that.

Thanks!

Answered by DTS Engineer in 136960022

The standard tool for this sort of thing is

lsregister
:
$ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump
… lots of output …

You could post-process the output to generate something more focuse.

WARNING Do not ship anything that depends on the presence or output of this tool. Its location, deep within the Core Services framework, indicates that it’s not something that’s officially supported.

ps

launchd
(and hence
launchctl
) and Launch Services operate at very different layers within the OS (
launchd
is the fundamental process management abstraction on the system, which Launch Services is a relatively high-level API). You should not expect to find anything related to Launch Services within
launchctl
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer

The standard tool for this sort of thing is

lsregister
:
$ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump
… lots of output …

You could post-process the output to generate something more focuse.

WARNING Do not ship anything that depends on the presence or output of this tool. Its location, deep within the Core Services framework, indicates that it’s not something that’s officially supported.

ps

launchd
(and hence
launchctl
) and Launch Services operate at very different layers within the OS (
launchd
is the fundamental process management abstraction on the system, which Launch Services is a relatively high-level API). You should not expect to find anything related to Launch Services within
launchctl
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

What are you going to do with the path once you've found it? For example, if you're just going to launch it, then you can use /usr/bin/open with the -b option.


If you don't find anything else, you can actually invoke NSWorkspace from python using PyObjC. Something like:

python -c 'from AppKit import * ; print NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier_(u"com.apple.TextEdit")'
Launchctl command line equivalent of “absolutePathForAppBundleWithIdentifier(”com.bundle.helper")
 
 
Q