Introjucer- add String in preprocessor definitions for XCode


I tried to add a preprocessor definition to a project exporter and it was containing a string like this:

That won’t load in XCode, telling me that the file is corrupted. I tried to add backslashes like this:FILE_NAME=\"filename.txt\"
But it did not work either.

How can I add a preprocessor definition that replaces this line of code: #define FILE_NAME "filename.txt"

Thank you

1 Like

You can’t - because the “define” will overwrite your preprocessor definition.

To make it possible the code should be

#ifndef FILE_NAME #define FILE_NAME "filename.txt" #endif

I’ve added a tweak to the introjucer to deal with quotes now - try it again.

Thanks Jules,

unfortunately it still causes problems… I tried this:FILE_PATH="file"
Now the project loads, but Xcode wont read this as a string. I noticed, when entering these definitions manually into the project settings in xcode I had to write this to make it work: FILE_PATH=\"file\"
The result now looks like these leading backslashes aren’t added yet.

@chkn: I don’t want to replace an existing definition in my code - I want to have a preprocessor definition, that would do the same as the above noted “#define …” statement. So “replacement” was probably the wrong word for it. But I think jules understood :slight_smile:

Thanks for your effort!

Well, I haven’t time to dig any deeper right now - the relevant code is in jucer_ProjectExport_XCode.h, line 789 if you want to tinker with it yourself.

Just ran into this bug on latest Projucer.

The problem seems to be that the quotation mark " is being escaped with a backslash \ too early in the process and later on everything gets escaped again yielding this:


instead of this:


Could you take a look at it again, @jules?