Roger
What you are looking for is a way to set GCC_PREPROCESSOR_MACROS using the xcodebuild command-line tool. The man page for xcodebuild shows the format for applying these parameters, however the SYNOPSIS section only refers to this as "setting = value ..."
xcodebuild [-project projectname] -scheme schemename [-configuration configurationname] [-sdk [sdkfullpath | sdkname]] [buildaction ...] [setting=value ...] [-userdefault=value ...] xcodebuild -workspace workspacename -scheme schemename [-configuration configurationname] [-sdk [sdkfullpath | sdkname]] [buildaction ...] [setting=value ...] [-userdefault=value ...]
Ultimately, you have the opportunity to set any assembly parameter values โโdirectly on the command line, using this format and knowing the name of the actual assembly name that you want to change. Naturally, this raises the question ...
How to find assembly settings names?
Glad you asked! The Xcode 4 sidebar is the easiest place to search for the actual installation name using the command line.

When searching for a build customization name, the Quick Help Inspector of the Xcode 4 Utilities prompt is the place to look.
- Open the build settings screen of your project.
- Make sure that the sidebar (that Xcode calls "Utilities") is visible by clicking the "Utilities" button next to the "Organizer" button in the upper right corner of Xcode.
- In the Utilities sidebar, verify that the Quick Help Inspector is visible.
Alternatively, use Option + Command + 2 to immediately see the Quick Help Inspector!
Finally, you are ready to find your build setup:
- Either search for the build settings you want to change, or scroll through the list of build settings.
- Click on the assembly installation you are interested in and view the Quick Help Inspector update.
- The Declaration section of the Quick Help Inspector shows the name of the command-line option you want to use.
In the case of the preprocessor Macros settings that you originally asked about, this parameter:
GCC_PREPROCESSOR_DEFINITIONS
Combining this with the original question, you can set this build option on the command line simply by providing SETTING_NAME = 'DESIRED_VALUE' along with the rest of your xcodebuild command. In the case of a quick little test project, I dropped โTestAppโ together, where I wanted the โBKMโ preprocessor macro to be set to 1, my xcodebuild command:
xcodebuild -project TestApp.xcodeproj -scheme TestApp GCC_PREPROCESSOR_DEFINITIONS = '$ {inherited} BKM = 1'
Why did you insert $ {inherited} there?
If you use preprocessor macros, you probably have more than one that you are using. Some of which you may not want to change from the command line, but are still encoded in the target or project build settings. Using '$ {inherited}' instructs xcodebuild to also use build settings defined at a higher level, instead of using only those that we defined in the xcodebuild command. In most cases, you will want to use $ {inherited} to use any of your customized values.
Does value need to be wrapped in apostrophes?
If you want to set more than one value, then yes, you will need to wrap the value in the apostrophe, otherwise, if you install two or more preprocessor macros from the command line, the second + macro will be interpreted as a construction parameter instead of the Macro preprocessor ... not quite right behavior. Apostrophes act as a way of collecting multiple values โโfor customization together. In the case of my xcodebuild command for example, I wanted xcodebuild to use an Inherited set of preprocessor macros along with my specific BKM parameter, so I wrapped the value in the apostrophe to tell xcodebuild to treat them like preprocessor macros.
Will this work with workspaces?
Absolutely! Just change the command to use the -workspace parameter instead of the -project parameter and you will be in business!