2

In our project we have two compilation conditions defined in our project's xcconfig files which we're using like so:

#if FOO_VERY_LONG_NAME && BAR_VERY_LONG_NAME
    ...
#endif

For convenience, I'd like to reduce these into a single compilation condition in the xcconfig file like so:

#if FOOBAR
    ...
#endif

I am very nearly able to combine them using this solution in my xcconfig file:

// FOO && BAR
FOOBAR_NO_NO = NO
FOOBAR_NO_YES = NO
FOOBAR_YES_NO = NO
FOOBAR_YES_YES = YES

FOOBAR_FLAGS_YES = FOOBAR
FOOBAR_FLAGS_NO =

FOOBAR_BOOL = $(FOOBAR_$(FOO:default=NO)_$(BAR:default=NO))

SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) $(FOOBAR_FLAGS_$(FOOBAR_BOOL))

The issue with the solution above is that FOO and BAR always resolve to NO. This is because FOO and BAR are appended to SWIFT_ACTIVE_COMPILATION_CONDITIONS at some earlier point in the project configurations, but are not explicitly defined with a YES/NO value of their own.

I've solved the issue by explicitly defining FOO=YES and/or BAR=YES where appropriate, so at this point my question is more academic than anything else.

Does anybody know a way to check for the presence of a condition in SWIFT_ACTIVE_COMPILATION_CONDITIONS from within the xcconfig file?

0 Answers0