xcodeswiftrun-script

How to use Swift Flags inside a Run Script Build Phase in Xcode?


I added "-D MYOWNFLAG" to Other Swift Flags in Build Settings of Xcode. Now, in my Run Script found in Build Phases, I want to check for the existence of the flag "MYOWNFLAG" and execute something (e.g. change Info.plist setting value) if it exists.

Is this possible? If yes, what is the best way to do this?


Solution

  • You can check all available environment variables by running printenv from within a runscript phase.

    The Other Swift Flags can be printed by running:

    echo $OTHER_SWIFT_FLAGS
    

    from within your runscript phase