Search code examples
bashxcodebuild

OSX/Bash - detecting build failure


Using Xcodebuild directly from bash, how would one detect a failure? the exit code is always 0 regardless. I realize there's an "FAILED" or "SUCCEEDED" textural output, but isn't there a more elegant way?

Also, I sometimes use "make" (especially with my Qt based builds). Is there a way to detect make has failed from the build script?


Solution

  • Maybe it depends on the version of Xcode or possibly how it fails. This is what I get when I check $? after some include files can't be found:

    davidb@DavidBs-Mobile-Macintosh:~/Source/icanvas/iCanvas-project (release/icanvas-1.9 %) $ xcodebuild
    ...
    /Users/davidb/Source/icanvas/iCanvas-project/iCanvas-target/iPhone/ConversationViewController.m:21:9: fatal error: 'CanvasKit/CKActionSheetWithBlocks.h' file not found
    #import "CanvasKit/CKActionSheetWithBlocks.h"
            ^
    1 error generated.
    ...
    ** BUILD FAILED **
    ...
    (5 failures)
    davidb@DavidBs-Mobile-Macintosh:~/Source/icanvas/iCanvas-project (release/icanvas-1.9 %) $ echo $?
    65