xcode 捆绑包名称和捆绑包显示名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9667582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bundle Name and Bundle Display Name
提问by Boon
Similar question about Bundle Name and Bundle Display Name have been asked, such as:
已经提出了关于 Bundle Name 和 Bundle Display Name 的类似问题,例如:
可可应用程序的信息 plist 中的“捆绑显示名称”和“捆绑名称”有什么区别
but so far I have not read a very good succinct answer on when you need to use them both, when they may be specified differently, and so on.
但到目前为止,我还没有读到关于何时需要同时使用它们、何时可以以不同方式指定它们等的非常简洁的答案。
The documentation seems to suggest that bundle display name is only useful if you have localization and may hurt performance if you specify it when you don't have localization.
该文档似乎表明 bundle display name 只有在您进行本地化时才有用,如果在没有本地化时指定它可能会损害性能。
Can someone clear these issues once and for all?
有人可以一劳永逸地解决这些问题吗?
Apple's Documentation
苹果的文档
CFBundleName (String - iOS, Mac OS X) identifies the short name of the bundle. This name should be less than 16 characters long and be suitable for displaying in the menu bar and the application's Info window. You can include this key in the InfoPlist.strings file of an appropriate .lproj subdirectory to provide localized values for it. If you localize this key, you should also include the key “CFBundleDisplayName.”
CFBundleDisplayName (String - iOS, Mac OS X) specifies the display name of the bundle. If you support localized names for your bundle, include this key in both your information property list file and in the InfoPlist.strings files of your language subdirectories. If you localize this key, you should also include a localized version of the CFBundleName key.
If you do not intend to localize your bundle, do not include this key in your Info.plist file. Inclusion of this key does not affect the display of the bundle name but does incur a performance penalty to search for localized versions of this key.
Before displaying a localized name for your bundle, the Finder compares the value of this key against the actual name of your bundle in the file system. If the two names match, the Finder proceeds to display the localized name from the appropriate InfoPlist.strings file of your bundle. If the names do not match, the Finder displays the file-system name.
CFBundleName(字符串 - iOS、Mac OS X)标识包的短名称。此名称应少于 16 个字符,适合显示在菜单栏和应用程序的信息窗口中。您可以将此键包含在相应 .lproj 子目录的 InfoPlist.strings 文件中,以为其提供本地化值。如果您本地化此键,则还应包含键“CFBundleDisplayName”。
CFBundleDisplayName (String - iOS, Mac OS X) 指定包的显示名称。如果您支持捆绑包的本地化名称,请在您的信息属性列表文件和语言子目录的 InfoPlist.strings 文件中包含此键。如果您本地化此键,您还应该包含 CFBundleName 键的本地化版本。
如果您不打算本地化您的包,请不要在您的 Info.plist 文件中包含此键。包含此键不会影响包名称的显示,但会导致搜索此键的本地化版本时的性能损失。
在显示包的本地化名称之前,Finder 会将此键的值与文件系统中包的实际名称进行比较。如果这两个名称匹配,Finder 将继续显示来自您的包的相应 InfoPlist.strings 文件的本地化名称。如果名称不匹配,Finder 将显示文件系统名称。
回答by Ethan Parker
CFBundleDisplayNameis for changing the text below the app icon on your device (and simulator). Yes this is supposed to be localized but there's no tangible penalty in performance to editing it or making it say whatever you want.
CFBundleDisplayName用于更改设备(和模拟器)上应用程序图标下方的文本。是的,这应该是本地化的,但是编辑它或让它说出你想要的任何内容并没有明显的性能损失。
To edit this, you can change the "Bundle display name under "info" in the project:
要编辑它,您可以更改项目中“信息”下的“捆绑显示名称”:
CFBundleNamenot a clue. I can't figure out what this changes or why.
CFBundleName不是线索。我无法弄清楚这是什么变化或为什么。
回答by DevAndArtist
I just found this document at Apples iOS Dev Library: Making the app name displayed on a device consistent with the name in iTunes Connect.The name is a little misleading, but this solved my understanding about the difference between 'Bundle name' and 'Bundle display name' in an instant.
我刚刚在 Apples iOS Dev Library 找到了这个文档:使设备上显示的应用程序名称与 iTunes Connect 中的名称一致。这个名字有点误导,但这一下子解决了我对“捆绑名称”和“捆绑显示名称”之间区别的理解。
I hope this will help you guys too. :)
我希望这也能帮助你们。:)
回答by Manish Gupta
for iOS (not sure about macOS or watchOS)
适用于 iOS(不确定 macOS 或 watchOS)
CFBundleName - is the fallback if CFBundleDisplayName is not present in the info.plist. Moreover the CFBundleDisplayName is used by Siri.
CFBundleName - 如果 CFBundleDisplayName 不存在于 info.plist 中,则回退。此外, Siri 使用 CFBundleDisplayName。
If you localize CFBundleDisplayName, you must localize CFBundleDisplayName as well.
如果您本地化 CFBundleDisplayName,您也必须本地化 CFBundleDisplayName。
Here is the apple link for the same - https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-110725