包标识符

在macOS中每一个软件,无论它是应用,还是包(bundle,其实app也是一种bundle)都有一个包标识符属性,该属性名称叫CFBundleIdentifier。这个标识符的内容是反向的DNS名称字符串,字符串只能包含罗马的大小字母、点(.)和下划线(_)(详细请参考苹果Core Foundation Keys文档)。包标识符和包的显示名称(CFBundleDisplayName)以及短名称(CFBundleName)是不一样的,比如Photos.app的名称是Photos,它的包标识符是:com.apple.Photos。在很多时候,包标识符是一个包的唯一全局标识符,在macOS系统中,包标识符唯一对应一个程序/应用/包,不同的包不能具有相同的标识符。

要查看一个包的包标识符,使用下面的命令: $ defaults read /path/to/the/bundle/Contents/Info.plist CFBundleIdentifier

比如查看Photos.app标识符的命令是: $ defaults read /Applications/Photos.app/Contents/Info.plist CFBundleIdentifier com.apple.Photos

而Finder的是(注意:换行的部分依然是命令行的一部分): $ defaults read /System/Library/CoreServices/Finder.app/Contents/Info.plist CFBundleIdentifier com.apple.finder

Last updated