OSX / Bash - build failure detection

Using Xcodebuild directly from bash, how can a failure be detected? The exit code is always 0 regardless. I understand that the texture output is “FAILED” or “SUCCEEDED,” but is there a more elegant way?

In addition, I sometimes use "make" (especially with my Qt-based strings). Is there any way to detect that make worked from the build script?

+6
source share
3 answers

Perhaps this depends on the version of Xcode or, possibly, on its failure. Is this what I get when I check $? after some include files cannot 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 
+1
source

xcodebuild always returns 0 even if the build fails. To detect errors, you can use the script as follows:

 build_errors_file=build_errors.log # Pipe errors to file xcodebuild 2>$build_errors_file errors=`grep -wc "The following build commands failed" $build_errors_file` if [ "$errors" != "0" ] then echo "BUILD FAILED. Error Log:" cat $build_errors_file rm $build_errors_file exit 1 fi rm $build_errors_file # ... continue 

I confirmed that ** BUILD FAILED ** will not be printed when xcodebuild starts with the archive parameter, so it seems that the line to look for is "The following build commands failed."

+6
source

The exit code is not always 0.

I assume you ran xcodebuild from a shell script.

You can try putting #! / Bin / bash -e in front of your script file.

fooobar.com/questions/583918 / ...

0
source

All Articles