8

I'm trying to launch xcodebuild with different preprocessing macros.

I've tried :

xcodebuild -scheme myscheme \
           -configuration "Archive" \
           -sdk "iphoneos5.1" 
           archive \
           CONFIGURATION_BUILD_DIR=../build \
           GCC_PREPROCESSOR_DEFINITIONS=ADHOC

but i got a compilation error due to the fact the preprocessor was not used:

I couldn't see it with the -D flag of the compilation command

But it is displayed at the beginning of the script

Build settings from command line:
        CONFIGURATION_BUILD_DIR = ../build
        GCC_PREPROCESSOR_DEFINITIONS = ADHOC
        SDKROOT = iphoneos5.1

The code at the origin of the compilation error is:

#ifdef ADHOC
NSUInteger toto = 0;
#endif

but i get a use of undeclared identifier error for toto

ps : if i do define Preprocessor Macros in Xcode, then these values are used, mine are overridden, and archiving is done. But I do want to make several builds based on different preprocessor definitions (which sounds a better idea than creating new build configurations or schemes to me)

7
  • It seems to be working for me. Can you provide a sample project that demonstrates the problem? Commented Mar 22, 2012 at 16:30
  • 1
    By the way, I disagree that preprocessor definitions are the best approach here. They are inherently more limited than the alternatives. Have you considered using one schema, one configuration, but multiple targets? Commented Mar 22, 2012 at 16:31
  • 1
    i already experienced multiple targets in a project and hated it: too many checkboxes to check any time you include new code to a project. But maybe it would make sense here. Commented Mar 22, 2012 at 16:37
  • what version of Xcode are you using? (mine is 4.3.1 - Build version 4E1019). i'll try to create a small project to demonstrate the problem soon... Commented Mar 22, 2012 at 16:42
  • I'm using the same version of Xcode as you. Commented Mar 22, 2012 at 17:01

1 Answer 1

2

I have to use double quote and remove the $value. I had,

GCC_PREPROCESSOR_DEFINITIONS='$value ${e}', 

which did not work, but

GCC_PREPROCESSOR_DEFINITIONS="${e}" 

works.

Where, e is variable inside a loop,

environments=("TEST1" "TEST2" "TEST3" "TEST4" "TEST5" "PROD")
for e in "${environments[@]}"
   do
....... commands
   done

If I use

GCC_PREPROCESSOR_DEFINITIONS='$value ${e}'

Then I have to use like,

GCC_PREPROCESSOR_DEFINITIONS='$value ADHOC=1'

This worked in one of build script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.