Skip to content

Instantly share code, notes, and snippets.

@rickfillion
Created October 25, 2013 17:33
Show Gist options
  • Save rickfillion/7158618 to your computer and use it in GitHub Desktop.
Save rickfillion/7158618 to your computer and use it in GitHub Desktop.
git pre-commit hook for stopping you from commiting xibs that are in the new Xcode5 format that won't load in Xcode4. Surely there's a better way to find xibs that are in the new format than this, but it seems to work so far. To use: Save as .git/hooks/pre-commit.
#!/bin/sh
#
# Pre-Commit Hook that checks for Xcode5 format XIB files as they won't be
# openable in Xcode4
# Redirect output to stderr.
exec 1>&2
xcode5xibs=`find . -name *.xib -exec grep "<document.*type=\"com.apple.InterfaceBuilder3.Cocoa.XIB\"" {} + | sed -e 's/:.*//'`
if [ "$xcode5xibs" != "" ]
then
echo "Error: Attempt to add an Xcode5 xib file"
echo "$xcode5xibs"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment