I am trying to maintain two bundle identifiers for the same app: one for the development state, another for the AppStore. This allows me to have both the 'official' version and the development version installed on the exact same device without conflict.
What I need is a simple way to control the bundle identifier through a header file. In Xcode, I have specified the following settings:
- Preprocess Info.plist File set to Yes;
- Info.plist Preprocessor Prefix File set to
ux_defines.h.
The ux_defines.h goes as follows:
// Set this to 0 to switch bundle id to official
#define USE_DEBUG_PRODUCT 1
#if (USE_DEBUG_PRODUCT == 1)
# define MACRO_APPID com.companyname.appname_dbg
#else
# define MACRO_APPID com.companyname.appname
#endif
In Info.plist, I have specified the Bundle Identifier as follows:
<key>CFBundleIdentifier</key>
<string>MACRO_APPID</string>
However, when I build for the device, Xcode always gives me an error: Failed to code sign "App Name". On the other hand, everything works smoothly if I keep the bundle identifier hard-coded but define a custom option in Info.plist. For example, the following option:
<key>FooBar</key>
<string>MACRO_APPID</string>
...is correctly preprocessed into:
<key>FooBar</key>
<string>com.companyname.appname_dbg</string>
... or
<key>FooBar</key>
<string>com.companyname.appname</string>
... depending on the value of MACRO_APPID in the header. The error seems only specific to the bundle identifier.
How can I set up the project and avoid these errors?