Skip to content

Instantly share code, notes, and snippets.

@dstnbrkr
Created December 6, 2011 23:47
Show Gist options
  • Select an option

  • Save dstnbrkr/1440655 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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

@dstnbrkr
Copy link
Copy Markdown
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