How to stop Xcode build from shell script
Another useful technique is for the script to produce an output with an "error: " prefix.This will cause Xcode to show the error within the build logs, and if you Xcode settings stop building on failure - it will stop right there.
In addition to this, you could also trigger a warning by printing out "warning: " prefix.
Example:
if [ -d ~/Desktop/MyFolder ]; then cp -r ~/Desktop/MyFolder ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MyFolderelse echo "error: Copy failed!"fi