Info.plist preprocessing appears to have issues

The environment

We have a rather large project, where the main app is ReactNative/Expo, and there are some native extensions and components.

We are building two flavors, development and production, and these are deployed as separate applications, with separate bundle ids. Let's call them com.example.dev and com.example.prod. These flavors are build via Schemes. For each flavor, four variants exist ("debug", "release", "appstore", and "automation"

The two flavors thus have different Shared Group Idenfiers (group.com.example.dev and group.com.example.prod, and we use a shared container to share data between this apps.

The Main Objective

We want to share the group identifier between the main app and its various extensions. If you have a better idea than what we are describing, please absolutely say so. I'd rather solve the problem, than care about details.

The Solution

We are putting the setting into a react native .env file, which is read by the react native parts and is basically structured like an .xcconfig file. For example, the debug.env file looks like this:

BUILD_CONFIG=debug
SHARED_GROUP_NAME_IOS=group.com.example.dev

Then, there is a debug.xcconfig file, which includes the pods.xcconfig, and the debug.env file:

#include "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"

#include "../../react-native-config/debug.env"

Side node: People who know about ReactNative files may interject that these environment variables should be available because there is a build setting INFOPLIST_PREFIX_HEADER = ${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h

This, however does not seem to work for me, not in this nor in a a sample project.

Finally, the Info.plist contains:

	<key>SharedGroupName</key>
  <string>$(SHARED_GROUP_NAME_IOS)</string>

The idea then is that the app and the extensions can simply retrieve this value using Bundle.main.object(forInfoDictionaryKey: "SharedGroupName)

The Issue

Because the SharedGroupName key remained empty in the generated plist. I took a look at the Preprocessed-Info.plist in the build output, and found something extremely curious:

    <key>SharedGroupName</key>
  <string>$(group.com.example.dev)</string>

So the variable was substituted with another variable! And thus, it ultimately get's resolved to an empty string

  • Am I doing it wrong? At what point, in the build settings, the variable seems to resolve correctly
  • How can I possibly debug this better?
  • Is this a bug?

Thanks for any hints or insights you might have

Answered by below in 756143022

Answering to myself: Works as designed

The trick here is that INFOPLIST_PREPROCESS = YES, and that the defines are in the preprocess header. To make it work like about, turn off INFOPLIST_PREPROCESS.

What I actually was is to keep it on, get rid of the .xcconfig files entirely, and use

	<key>SharedGroupName</key>
    <string>SHARED_GROUP_NAME_IOS</string>

which solved my primary problem

Accepted Answer

Answering to myself: Works as designed

The trick here is that INFOPLIST_PREPROCESS = YES, and that the defines are in the preprocess header. To make it work like about, turn off INFOPLIST_PREPROCESS.

What I actually was is to keep it on, get rid of the .xcconfig files entirely, and use

	<key>SharedGroupName</key>
    <string>SHARED_GROUP_NAME_IOS</string>

which solved my primary problem

Info.plist preprocessing appears to have issues
 
 
Q