Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone/Xcode: can different project targets have different bundle identifiers?

Tags:

xcode

iphone

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

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.

So which is it that takes precedence? The Target info\Properties\Identifier bundle ID or the Info.plist bundle 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).

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?

like image 470
Rob Avatar asked Apr 27 '09 03:04

Rob


People also ask

Can I change bundle identifier in XCode?

Change the Bundle IDChoose your project from the left side, then your app target under TARGETS, select the General tab and rename the Bundle Identifier.

What is the difference between app ID and bundle ID in iOS?

An App ID is a string used to identify one or more apps from a single development team. The string consists of two parts, the Team ID and the bundle ID separated by a period (.). The Team ID is supplied by Apple, while the bundle ID is supplied by the developer.

How can you change the unique bundle identifier for a mobile build?

You can modify the bundle identfier in ProjectSettings. asset that way: Edit > Project Settings > Player > Android > Other Settings > Package Name. You might want to change it for all platforms since this field is separate by each platform. ProjectSettings.

What is the difference between project and target in XCode?

A target specifies a product to build, such as an app, framework, app extension, or unit test. A project can contain multiple targets, usually representing related parts of a single product. For example, a project might contain separate targets for an app, a private framework, an app extension, and a suite of tests.


1 Answers

There isn't a precedence, the properties dialog is just serving as another way for you to see your 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:

<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.

like image 88
smorgan Avatar answered Oct 09 '22 01:10

smorgan