A good boy scout "leaves the campground cleaner than he found it". Or at least, not leave the campground messier than he found it. In iOS this includes those 'misplaced views' warnings that Xcode sometimes unhelpfully causes, when you merely peek at .xib files.

Future Xcode releases will hopefully fix this. But for now, it's still up to us to fix it. The following Git hook ensures all team members keep the campground clean for others:

#!/usr/bin/env bash
set -e

failed=0

misplaced_pattern='misplaced="YES"'
if git diff-index -p -M --cached HEAD -- '*.xib' '*.storyboard' | grep '^+' | egrep "$misplaced_pattern" >/dev/null 2>&1
then
  echo "PUSH REJECTED, you have misplaced views:" >&2
  echo "$(git --no-pager grep -l --cached "$misplaced_pattern" '*.xib' '*.storyboard')" >&2
  echo ""
  failed=1
fi

# Potentially more checks that raise the 'failed' flag.

exit $failed