8

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?

Dj S
  • 10,232
  • 1
  • 21
  • 24

2 Answers2

10

Should be able to use wildcards in conjunction with the $OTHER_SWIFT_FLAGS env variable.

if [[ $OTHER_SWIFT_FLAGS == *"-D MYOWNFLAG"* ]]; then
  echo "execute something (e.g. change Info.plist setting value)"
fi
apparition47
  • 461
  • 6
  • 8
6

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

Max Chuquimia
  • 7,494
  • 2
  • 40
  • 59
  • 1
    how do i get a particular flag? like, i have added DEBUG flag and now i wanna check that in script execution. – Cerlin Sep 25 '17 at 08:07