You need to omit the braces.
When you say "preprocessor macros", are you setting up a user-defined environment build setting, or are you actually assigning values to the "Preprocessor Macros" build setting? If it's the latter, I don't think pre-processor macro definitions are available to run scripts except through the GCC_PREPROCESSOR_MACROS environment variable which is set from the build settings. If you are setting the value for "myflag" in the build settings via the GCC_PREPROCESSOR_MACROS (the "Preprocessor Macros" build setting), you'll have to parse the whole macro definition to find "myflag"
You can set user-defined environment variables for Xcode via .xcconfig files (look up "xcconfig" files in Xcode documentation, and/or the Internet).