Lukasz Lukasz - 4 months ago 54
Objective-C Question

Invalid preprocessing directive for #elseifdef in Xcode

Why:

#ifdef SOME_TARGET_FLAG
<some code here>
#elseifdef SOME_ANOTHER_TARGET_FLAG
<some another code here>
#endif


produces "Invalid preprocessing directive" preprocess compilation error?

SOME_TARGET_FLAG and SOME_ANOTHER_TARGET_FLAG are just some "Other C-flags" defined in target build settings (
-D<FLAG_NAME>
pattern).

Is #elseifdef directive not supported by Xcode?

Answer

Is #elseifdef directive not supported by Xcode?

It is not. Use this instead:

#elif defined(SOME_ANOTHER_TARGET_FLAG)