Jabbering Giraffe

Run Script Phase

Some things I’ve discovered in the past few days about Run Script phases in Xcode…

  1. Name them after what they do. It’s no use looking at three identical phases, all of which say “Run Script”.
  2. It’s a good idea to always stick a set -x at the top. It’s only build output, so being verbose isn’t a bad idea. It’ll be really handy for debugging later on.
  3. If the script’s more than a line or two, consider sticking it in an external file and sourcing it instead. This is much more amenable to version control. For example:
    set -x
    . "${PROJECT_DIR}/bin/My_Script_Phase.sh"
    

    Note that you can also pass command line arguments in here, so you can greatly reduce the cut’n’paste between similar phases of different targets, if you’ve got that complex a build.