Projucer Extra Preprocessor Definition with space -> issue

Hi, I’m trying to add this preprocessor definition for an Xcode project, in the Projucer’s Extra Preprocessor Definitions field:

BUILD_NUMBER=`git rev-parse --short HEAD`

This is split by Xcode into multiple definitions due to the spaces inside of it, which can be resolved in Xcode by escaping the spaces:

BUILD_NUMBER=`git\ rev-parse\ --short\ HEAD`

So going back to the Projucer and writing this in the Extra Preprocessor Definitions field, I expected it to get through to the Xcode project config without the split; however for one reason or another the escaping gets lost and the definitions are again split across multiple lines in the Xcode project. Double-escaping yields no better result.

Hi fbecker,

How would you normally go about doing this for an Xcode project without using the Projucer? It seems that multi-word commands are automatically split by Xcode into multiple, separate preprocessor definitions even if you enter them into Xcode directly.


Hi Ed,
If you escape the spaces in the Xcode config ("\ "), Xcode doesn’t split the definition.

OK, thanks for the info. Working on a fix now.


Hi fbecker,

So to add a preprocessor definition with spaces to Xcode via the Projucer’s extra preprocessor definitions field you need to escape the backslash and then escape the space, so you need to use 3 backslashes. So for your command you would need to enter this in the Projucer:

BUILD_NUMBER=`git\\\ rev-parse\\\ --short\\\ HEAD`

which appears in Xcode’s preprocessor definitions as:

BUILD_NUMBER=`git\ rev-parse\ --short\ HEAD`

Hope this helps!

1 Like

Hi there,
I’m facing basically the same problem and I can’t seem to make this work.

MY_MACRO=Hello\ World

Still makes the Xcode project split the definition into 2 separate lines.

Did you try the advice in this thread?

MY_MACRO=Hello\\\ World

Yes, unfortunately it leads to this

I don’t want backslashes, just a simple whitespace between Hello and World.

The backslash is an escape character and is required to stop Xcode from splitting the define into 2 separate defines. Try the following, where MY_MACRO is defined as Hello\ World:


It’ll print Hello World to the console.

Yeah, my problem is actually more complex, since I’m actually redefining
JucePlugin_Name and this definition is used by Juce in many places without the JUCE_STRINGIFY bit.

That seems a bit dodgy, but the following should work:

JucePluginName="some\\\ name\\\ with\\\ spaces"

Yes, this seems to work.
About the dodgy part: what I’d like to have is a single .jucer project, where each exporter has multiple targets. In each target I’d like to redefine all the data so I can make multiple plugins based on a single project.
Thanks Ed!