问题
In many of my apps I have 3 different build configurations (debug, release, sandbox). One experiences this is needed needed when working with different environments and in app purchase.
Often there are only small changes like CFBundleIdentifier
. Is it possible to use GCC preprocessor macros for keeping the variation within different build configurations and at the same time only use one plist?
回答1:
For simple changes it is often not even necessary to use the C preprocessor. In these cases it is often sufficient to define a custom build setting and use the value of this setting in the Info.plist file. Build settings are expanded in Info.plist by default.
Example:
In Xcode in the project view select "Build Settings" and use the + button to add a "User-Defined Setting". Name the setting for example MY_BUNDLE_IDENTIFIER
and type a value, for example MyApp.agens.no
.
The open the Info.plist file, select the "Bundle identifier" key and set its value to ${MY_BUNDLE_IDENTIFIER}
.
If you change the MY_BUNDLE_IDENTIFIER
build setting in another configuration or target, the product will be built using the new bundle identifier.
来源:https://stackoverflow.com/questions/21256338/shared-info-plist-between-several-targets-using-gcc-preprocessor-macros-for-main