How to get Bundle ID of Mac application?

41.8k views Asked by At

I want to use Python and atomac module to trigger an application in macOS like following scripts:

atomac.launchAppByBundleID()
app_win = atomac.getAppRefByBundleId(app_bundle_ID)

But I don't know how to get the Bundle ID (app_bundle_ID) of the application.

3

There are 3 answers

0
DawnSong On

As we know, bundle id is located in the info.plist of an app, so both PlistBuddy and defaults could help

/usr/libexec/PlistBuddy -c 'print CFBundleIdentifier' /Applications/Xcode.app/Contents/Info.plist
or
defaults read /Applications/Xcode.app/Contents/Info.plist CFBundleIdentifier

which prints

com.apple.dt.Xcode

0
Yup On

if you just need it to launch the app look in the app's info.plist file. the file is in the app bundle in the Contents directory. This works for a lot of apps.

3
Qing On

I use two methods to get the bundler ID:

osascript -e 'id of app "SomeApp"'

and

mdls -name kMDItemCFBundleIdentifier -r SomeApp.app