Xcode 8.3 (8E162) entitlements files variables always resolve against debug configuration

Originator:keithbsmiley
Number:rdar://31383369 Date Originated:31-Mar-2017 17:20
Status:Resolved (duplicate of 31456053) Resolved:
Product:Developer Tools Product Version:Xcode 8.3 (8E162)
Classification:Serious Bug Reproducible:Always
 
Summary:
Starting with Xcode 8.3, entitlements files with variables that need to be resolved with a configuration's build settings, pulls the values of the variables from the Debug configuration instead of from the active configuration, resulting in the wrong values.

Steps to Reproduce:
1. Create a new iOS project
2. Add an entitlements file with the app groups entitlement
3. Edit the entitlements file to read $(SOME_VAR) to define the app group suite name
4. Define SOME_VAR in Xcode, but make it different between the Debug and Release configuration
5. Build the project from the command line with `xcodebuild -configuration Release`

Expected Results:
`SOME_VAR` is referenced from the Release configuration

Actual Results:
`SOME_VAR` is referenced from the Debug configuration

Version:
Xcode 8.3 (8E162)

Notes:
- See the attached example project and logs for an example
- Build it with `xcodebuild -configuration Release` (you may have to change the bundle ID first
- Also see `releasebuildsettings.txt` which was generated via `xcodebuild -configuration Release -showBuildSettings`. This has the correct value for `SOME_VAR`
- See `output.log` to see the output from running the above command. As you can see, the incorrect value is substituted.


Sample project: https://github.com/keith/radars/tree/master/EntitlementsFileSubstitution

Workarounds:

- Don't upgrade to Xcode 8.3
- Remove all configurations except the one you're trying to build before building. This can be scripted with [xcodeproj](https://github.com/CocoaPods/xcodeproj/)
- Duplicate your entitlements files across every config and don't use variables in them
- Pass the variables from the command line, instead of the build settings

Comments

Noticed that the bug is only during the static dependency checking process. If you can by pass the check somehow, the compiled entitlement file is correctly using configuration dependent variables.

By allen.sh.cn at April 6, 2017, 6:49 a.m. (reply...)

This also happens, when you provide a different value for a variable via the command line when invoking xcodebuild. It also just takes the original value from the build configuration and ignores the overridden one that is provided via the command line.

By matthias.schwab at April 3, 2017, 9:17 a.m. (reply...)

Sample project: https://github.com/keith/radars/tree/master/EntitlementsFileSubstitution

By keithbsmiley at April 1, 2017, 12:23 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!