Xcode Run Script Build Phase debugging

So I wanted to add a new build phase to my Xcode Project to run some shell script. It didn’t want to work and I’ve tried to find out why it didn’t work so I’ve tried some Logging. That turned out to be a bit tricky first as i’ve set Xcode to hide all messages and only show warnings and errors. To work around this you simply need to create warnings or errors. That’s pretty easy actually as you only need to write “warning: ohoh” or “error: meh” and Xcode will automatically annotate the message as warning or error:

echo "warning: ohoh"
echo "error: meh"

Error Messages in Xcode


3 Responses to “Xcode Run Script Build Phase debugging”

  1. Kelan Champagne Says:

    If you really want to get fancy, you can include a file path and line number (and the appropriate colons), and Xcode will open that when you double-click on the entry in the build log. The exact format is:

    file_path:line_num: [error|warning]: message goes here

    for example, from Python I use:

    print “%s:%d: %s: %s” % (filePath, lineNum, level, message)

    Not all custom build script warnings/errors will have an associated file and line, but if they do, this trick can be pretty handy.

  2. 0xced Says:

    You can also use echo “note: xxx”

  3. bitwise · Xcode Run Script Build Phase error reporting Says:

    […] thought about blogging about this several months ago, but never got around to it. And don’t skip reading the comments. […]