Skip to content

Instantly share code, notes, and snippets.

@pix0r
Created October 8, 2014 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pix0r/0022a927ad0ddc7bd685 to your computer and use it in GitHub Desktop.
Save pix0r/0022a927ad0ddc7bd685 to your computer and use it in GitHub Desktop.
Pre-commit hook to verify xcode project file has not been converted to XML
#!/bin/sh
PROJFILE=`find . -path \*xcodeproj/project.pbxproj -not -path \*Pods\*`
if [ "$PROJFILE" = "" ]; then
echo "Unable to locate project file; skipping pre-commit hook"
exit 0
fi
git stash -q --keep-index
file "$PROJFILE" | grep -i xml > /dev/null
RESULT=$?
git stash pop -q
if [ $RESULT -eq 0 ]; then
echo "Error: your project file is in XML format. Please re-save in Xcode before committing."
exit 1
else
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment