XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Support generating multiple Info.plist files for single target

Open yhkaplan opened this issue 5 years ago • 4 comments

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

  1. Is this already possible in some way I overlooked?
  2. Is this a feature you would benefit from me adding in a PR?
  3. Is there some alternate method people use instead of separate plists?

yhkaplan avatar Aug 26 '20 02:08 yhkaplan

  1. It's not currently possible to generate multiple per target
  2. It's come up once before, so happy for a PR
  3. Generation is just a convenience. You can still reference multiple plists that are checked in like normal, just by changing the INFOPLIST_FILE build setting per config

yonaskolb avatar Aug 27 '20 13:08 yonaskolb

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"

frederoni avatar May 10 '21 19:05 frederoni

Wow, didn’t know that, thanks @frederoni!

yonaskolb avatar May 11 '21 08:05 yonaskolb

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.

sroebert avatar Jul 28 '21 08:07 sroebert