[英]How to get Bundle ID of Mac application?
I want to use Python and atomac
module to trigger an application in macOS like following scripts:我想使用 Python 和
atomac
模块来触发 macOS 中的应用程序,例如以下脚本:
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.但我不知道如何获取应用程序的 Bundle ID (
app_bundle_ID
)。
I use two methods to get the bundler ID: 我使用两种方法来获取捆绑程序ID:
osascript -e 'id of app "SomeApp"'
and 和
mdls -name kMDItemCFBundleIdentifier -r SomeApp.app
if you just need it to launch the app look in the app's info.plist file. 如果只需要启动应用程序,请查看应用程序的info.plist文件。 the file is in the app bundle in the Contents directory.
该文件位于目录目录中的应用程序捆绑包中。 This works for a lot of apps.
这适用于许多应用程序。
As we know, bundle id is located in the info.plist of an app, so both PlistBuddy
and defaults
could help正如我们所知,bundle id 位于应用程序的 info.plist 中,因此
PlistBuddy
和defaults
都可以提供帮助
/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
com.apple.dt.Xcode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.