Skip to content

Instantly share code, notes, and snippets.

@lukestringer90
Created September 7, 2014 13:22
Show Gist options
  • Save lukestringer90/c1f44cbcbf92b9548c3e to your computer and use it in GitHub Desktop.
Save lukestringer90/c1f44cbcbf92b9548c3e to your computer and use it in GitHub Desktop.
Pre commit hook to run Xcode unit tests
#!/bin/sh
# A hook script to run Xcode unit tests before committing.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
WORKSPACE_PATH="path/to/your.xcworkspace"
SCHEME="scheme-name"
SDK="iphonesimulator"
DEFAULT_TASK="xcodebuild -workspace $WORKSPACE_PATH -scheme $SCHEME -sdk $SDK clean test"
# xcpretty makes output nicer
if hash xcpretty 2>/dev/null; then
$DEFAULT_TASK | xcpretty -t; exit ${PIPESTATUS[0]}
else
$DEFAULT_TASK
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment