Skip to content

Instantly share code, notes, and snippets.

@thefotes
Created June 28, 2015 19:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefotes/d7313ff9dad7964da61d to your computer and use it in GitHub Desktop.
Save thefotes/d7313ff9dad7964da61d to your computer and use it in GitHub Desktop.
Given a path to an Xcode project, loops through all files and checks to see if any files have been imported more than once in the same file.
#!/bin/bash
set -e
read -e -p "Enter path to Xcode project: " FILES
eval FILES=$FILES
find "$FILES" -type f \( -name "*.h" -or -name "*.m" \) | while read -r f;
do
MYVAR=$(sed -n '/^#import/p' "$f" | uniq -c | sed -n '/[2-9] #import/p' | sort -nr)
if [ -n "$MYVAR" ]; then
echo "$f"
echo "$MYVAR"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment