简体   繁体   中英

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

I have 3 different build configurations set up for my iOS Xcode project. 在此处输入图片说明

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.

在此处输入图片说明

INFO section-

在此处输入图片说明

BUILD SETTINGS-

在此处输入图片说明

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

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

在此处输入图片说明

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

在此处输入图片说明

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.

Jens' answer was a bit confusing to me. All you have to do is add the xcconfig declared variable ( PRODUCT_BUNDLE_IDENTIFIER = com.mycomp.hockey ) to the Info.plist product bundle identifier field:

Info.plist 变量示例

Also don't forget to declare it in every xcconfig file. Enjoy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM