Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode- how to set different bundle identifiers for different build configuration?

In Xcode settings's Info tab for project (not target's Info tab), I have 3 different build configurations, each with 2 .xcconfig files set up for my iOS Xcode project. enter image description here

I want to have different bundle identifiers for different configurations for better code signing management. Below are my general identity settings, info tab settings and bundle identifier settings under build settings.

enter image description here

INFO section-

enter image description here

BUILD SETTINGS-

enter image description here

When I update the bundle identifier directly in general section, the value in build settings --> Product Bundle Identifier gets overridden for all the build configurations.

Please suggest me a better way to manage this!!

like image 572
Rashmi Ranjan mallick Avatar asked Oct 18 '16 12:10

Rashmi Ranjan mallick


People also ask

Can I change bundle identifier in Xcode?

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

How do I change my product bundle identifier?

Under Targets > Build settings, scroll to Packaging. Change your Product name to the desired name & Product bundle identifier to the new one. Once you do this, automatically your project display name & bundle id changes to the new one in General tab.


1 Answers

As far as I can see, you have already set up individual xcconfig files for each configuration. That means you can just add the bundle identifier key with the corresponding value to each build configuration / xcconfig file.

PRODUCT_BUNDLE_IDENTIFIER = com.mycomp.hockey 

You need to make sure that you do not override these xcconfig settings in your Xcode project build settings (the corresponding value should not be bold).

If you want to switch between your bundle identifiers on the fly you might want to create one scheme per build configuration. That way you can just select the corresponding scheme in the Xcode scheme selector (next to the build/run button).

enter image description here

To create a new scheme, just select New scheme from the scheme selector and choose a name, e.g., MyApp [Hockey]. Then edit the scheme and select the preferred build configuration for each step, e.g., MyApp [Hockey] for the Archive step.

enter image description here

You will notice that the bundle identifier on your target info screen will change depending on the selected scheme. Sometimes you need to switch to a different tab of your project settings and then back to the Info tab before the bundle identifier changes (one of many Xcode bugs).

We use the exact same approach for all our projects.

Hope that helps.

like image 53
Jens Meder Avatar answered Oct 02 '22 17:10

Jens Meder