iPhone/Xcode:不同的项目目标可以有不同的包标识符吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/792170/
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
iPhone/Xcode: can different project targets have different bundle identifiers?
提问by Rob
I'm a little confused how this works - this is my understanding:
我有点困惑这是如何工作的 - 这是我的理解:
- A target's provisioning profile is linked to a specific app ID
- The bundle identifier for a target is found under Target info\Properies\Identifier
- 目标的配置文件链接到特定的应用程序 ID
- 目标的包标识符位于Target info\Properies\Identifier 下
But... bundle ID is also located in Info.plist. It seems that if you change the bundle ID in Info.plist, Xcode changes it automatically in Target info\Properties\Identifier, and vice versa.
但是……bundle ID 也位于 Info.plist 中。似乎如果您更改Info.plist 中的包 ID ,Xcode 会在Target info\Properties\Identifier 中自动更改它,反之亦然。
So which is it that takes precedence? The Target info\Properties\Identifierbundle ID or the Info.plistbundle ID?
那么哪个优先呢?该目标信息\属性\标识捆绑ID或Info.plist的捆绑ID?
The reason I ask is because I'd like to have two versions for my app - a free ad supported version and a paid version, and I'd like to accomplish that with two different targets. Since they will be two different apps in the App Store, my understanding is they need two different app IDs (and I don't want to go down the * route with app IDs, the description of how that works on the App Store made my brain hurt).
我问的原因是因为我想为我的应用程序提供两个版本 - 一个免费的广告支持版本和一个付费版本,我想通过两个不同的目标来实现这一目标。由于它们将是 App Store 中的两个不同的应用程序,我的理解是它们需要两个不同的应用程序 ID(而且我不想使用应用程序 ID 沿着 * 路线走下去,关于它在 App Store 上如何工作的描述使我伤脑筋)。
Would I need two different Info.plists for each target if I did this, or can I use the same Info.plist, and just have the different targets use a different development/distribution provisioning profile?
如果我这样做,我是否需要为每个目标使用两个不同的 Info.plist,或者我可以使用相同的 Info.plist,而只是让不同的目标使用不同的开发/分发配置文件?
回答by smorgan
There isn't a precedence, the properties dialog is just serving as another way for you to see your Info.plist.
没有优先级,属性对话框只是您查看 Info.plist 的另一种方式。
To share the plist between the targets but have different identifiers, make sure that the "Expand Build Settings in Info.plist File" option is enabled for both targets. Then, for each target, make a new user-created variable in the target settings for your bundle ID (e.g., APPLICATION_BUNDLE_IDENTIFIER, see here: https://stackoverflow.com/a/18472235/308315) and set it to the right value for that target. In your plist, put the following for bundle ID:
要在目标之间共享 plist 但具有不同的标识符,请确保为两个目标启用“扩展 Info.plist 文件中的构建设置”选项。然后,对于每个目标,在您的包 ID 的目标设置中创建一个新的用户创建的变量(例如,APPLICATION_BUNDLE_IDENTIFIER,请参见此处:https: //stackoverflow.com/a/18472235/308315)并将其设置为正确的值对于那个目标。在您的 plist 中,为包 ID 输入以下内容:
<key>CFBundleIdentifier</key>
<string>$(APPLICATION_BUNDLE_IDENTIFIER)</string>
The variable will be evaluated at build time for each target, so each will get the right bundle ID.
将在构建时为每个目标评估该变量,因此每个目标都将获得正确的包 ID。