在 Xcode 7 中使用捆绑标识符而不是产品捆绑标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33122484/
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
Use Bundle Identifier instead of Product Bundle Identifier with Xcode 7
提问by turingtested
After upgrading to Xcode 7 I have noticed that the CFBundleIdentifier has started to point to Product Bundle Identifier found in Build Settings/Packaging instead of the Bundle Identifier in the Info.Plist. Is there any way to change it back? Or will it simply work to point back to Bundle Identifier, i.e. write $(BUNDLE_IDENTIFIER) in the Product Bundle Identifier field?
升级到 Xcode 7 后,我注意到 CFBundleIdentifier 已开始指向 Build Settings/Packaging 中的 Product Bundle Identifier 而不是 Info.Plist 中的 Bundle Identifier。有什么办法可以改回来吗?或者它只是简单地指向捆绑标识符,即在产品捆绑标识符字段中写入 $(BUNDLE_IDENTIFIER) ?
回答by Daniel Zhang
You should keep the $(PRODUCT_BUNDLE_IDENTIFIER)
in your Info.plist and set your product bundle identifier in Build Settings > Product Bundle Identifierwith a value of something like com.mydomain.myappname
.
您应该将 保留$(PRODUCT_BUNDLE_IDENTIFIER)
在您的 Info.plist 中,并在Build Settings > Product Bundle Identifier 中设置您的产品包标识符,其值类似于com.mydomain.myappname
.
From the Xcode 7.0 release notes:
来自 Xcode 7.0 发行说明:
The new build setting Product Bundle Identifier (PRODUCT_BUNDLE_IDENTIFIER) is the recommended place to set the Bundle Identifier for a target. The target's Info.plist should be configured to use this build setting by referencing it as $(PRODUCT_BUNDLE_IDENTIFIER) in the value for the CFBundleIdentifier key.
Xcode offers to configure this for you when you accept the “Upgrade to recommended settings” project modernization in the issue navigator, unless your target preprocesses its Info.plist file. In that case you will need to configure this setting manually. This change is backwards-compatible to older versions of Xcode.
This change is required to make certain features work, such as On Demand Resources, if your target preprocesses its Info.plist file. (20887827)
新的构建设置产品包标识符 (PRODUCT_BUNDLE_IDENTIFIER) 是为目标设置包标识符的推荐位置。目标的 Info.plist 应配置为使用此构建设置,方法是在 CFBundleIdentifier 键的值中将其引用为 $(PRODUCT_BUNDLE_IDENTIFIER)。
当您在问题导航器中接受“升级到推荐设置”项目现代化时,Xcode 会为您提供配置,除非您的目标预处理其 Info.plist 文件。在这种情况下,您需要手动配置此设置。此更改向后兼容旧版本的 Xcode。
如果您的目标预处理其 Info.plist 文件,则需要进行此更改才能使某些功能(例如 On Demand Resources)工作。(20887827)