Skip to content

Instantly share code, notes, and snippets.

@dstnbrkr
Created December 6, 2011 23:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstnbrkr/1440655 to your computer and use it in GitHub Desktop.
Save dstnbrkr/1440655 to your computer and use it in GitHub Desktop.
Remove unused resources from xcode project.
#!/bin/sh
for f in `find Resources/Images -type f ! -name '*@2x.png' ! -name 'Default*.png'`; do
FILENAME=`basename $f`;
NUSAGES=`usages $FILENAME | wc -l | awk '{print $1}'`;
if [ $NUSAGES = 0 ]; then
echo $f;
fi;
done;
@esromneb
Copy link

esromneb commented Jul 9, 2012

this is great, but I get

./xcode-remove-unused.sh: line 4: usages: command not found

for each iteration of the loop. I've never even heard of this command line tool and I can't find any references. can you help me? thanks!!!

@dstnbrkr
Copy link
Author

dstnbrkr commented Jul 9, 2012

'usages' is another helper script, from this file: https://gist.github.com/1440673

That script isn't polished or set up for reuse (has my project name hardcoded), but the intent is to search the project directories for references to a filename, then list out the files that reference it (i.e. a class file with a reference to a particular image).

@esromneb
Copy link

Thank you so much for this! you really helped the http://joynme.com app out!

@dstnbrkr
Copy link
Author

Thanks! So glad this could be helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment