Shazron's Cordova (aka PhoneGap) Blog

at Adobe Systems Inc.

Xcode shell build phase, reporting of errors

with 6 comments

Found this useful information, regarding Xcode error reporting for shell build phases. For example, if we were to include JSLint in PhoneGap iPhone, we could format the errors this way below so code where the errors occur are easily editable:

In shell build phases you can write to stderr using the following format:
<filename>:<linenumber>: error | warn | note : <message>\n
It’s the same format gcc uses to show errors. The filename:linenumber part can be omitted. Depending on the mode (error, warn, note), Xcode will show your message with a red or yellow badge.
If you include an absolute file path and a line number (if the error occurred in a file), double clicking the error in the build log lets Xcode open the file and jumps to the line, even if it is not part of the project. Very handy.

Written by shazron

December 4, 2010 at 2:00 am

Posted in xcode

6 Responses

Subscribe to comments with RSS.

  1. This is just the info I was looking for, but can’t quite
    get it to work. I tried adding this line to my shell script: echo
    “$file:1:error: Subtext parse error” It did generate a line of
    output in the build log: BrokenItemDilemmaTwo.subtext:1:error:
    Subtext parse errorn But it did not have the right format for xcode
    to mark it red or count as an error. What was I doing wrong??
    thanks!

    Antoine

    December 21, 2010 at 4:53 pm

    • Make sure you output the error line to stderr, not stdout.

      shazron

      December 23, 2010 at 10:31 pm

  2. Could you go into more detail on how to integrate jslint into the xcode build process? A step by step guide would be great!

    Don

    January 17, 2011 at 5:42 pm

  3. It seems to work if I do this in my script:

    echo -e “MyFile.m:0: error : My Message\n” 1>&2

    (note the spaces before and after ‘error’ and its subsequent colon). I can’t get Xcode to display anything besides the white exclamation icon in a red octagon though, no matter what mode I used.

    shazron

    May 16, 2011 at 6:26 pm

  4. This produces a compiler warning with a yellow triangle and white exclamation point.

    echo “MyFileName.m”:1: warning: “My warning message”
    exit 0

    RGB World

    January 11, 2013 at 8:22 am

  5. a relative file path is fine

    Dominik Pich

    March 17, 2014 at 3:33 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,543 other followers

%d bloggers like this: