Support generating multiple Info.plist files for single target
I use separate Info.plist files for different build configurations, but they share many of the same values, so I would like to use XcodeGen to generate them. Looking through the documentation and existing GitHub issues, it doesn't appear that generating multiple Info.plist files for a single target is currently possible, so I have a few questions.
As for background info, the differences between the release and debug info.plists include: CFBundleDisplayName (${PRODUCT_NAME} Beta for debug builds), FacebookAppID, NSAllowsLocalNetworking, and some NSExceptionDomains (production versus staging environments for third party services).
- Is this already possible in some way I overlooked?
- Is this a feature you would benefit from me adding in a PR?
- Is there some alternate method people use instead of separate plists?
- It's not currently possible to generate multiple per target
- It's come up once before, so happy for a PR
- Generation is just a convenience. You can still reference multiple plists that are checked in like normal, just by changing the
INFOPLIST_FILEbuild setting per config
For posterity, you can overwrite individual values in the Info.plist with INFOPLIST_PREPROCESS and INFOPLIST_PREPROCESSOR_DEFINITIONS
Example:
<key>CFBundleDisplayName</key>
<string>MY_DISPLAY_NAME</string>
settings:
base:
INFOPLIST_PREPROCESS: YES
INFOPLIST_FILE: Info.plist
Staging:
INFOPLIST_PREPROCESSOR_DEFINITIONS: "MY_DISPLAY_NAME=AppStaging"
Production:
INFOPLIST_PREPROCESSOR_DEFINITIONS: "MY_DISPLAY_NAME=App"
Wow, didn’t know that, thanks @frederoni!
Unfortunately INFOPLIST_PREPROCESS only works for string related settings, not for dictionaries/booleans. I would for example like to add NSAppTransportSecurity only for the debug configuration. I think this feature could still add a lot of benefit.
Instead of INFOPLIST_PREPROCESS, you can btw also simply refer to settings using $(SETTING_NAME) name in the plist file.