Skip to content

Instantly share code, notes, and snippets.

@stonyw
Created April 9, 2013 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stonyw/5343868 to your computer and use it in GitHub Desktop.
Save stonyw/5343868 to your computer and use it in GitHub Desktop.
The shell to find unused images in iOS project.
Shell for finding unused images in iOS project
Source:
http://stackoverflow.com/questions/6113243/how-to-find-unused-images-in-an-xcode-project
Version 1:
#!/bin/sh
PROJ=`find . -name '*.xib' -o -name '*.[mh]' -o -name '*.storyboard' -o -name '*.mm'`
for png in `find . -name '*.png'`
do
name=`basename -s .png $png`
name=`basename -s @2x $name`
if ! grep -q $name $PROJ; then
echo "$png"
fi
done
Version 2:
#!/bin/bash
for i in `find . -name "*.png" -o -name "*.jpg"`; do
file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x`
result=`ack -i "$file"`
if [ -z "$result" ]; then
echo "$i"
fi
done
# Ex: to remove from git
# for i in `./script/unused_images.sh`; do git rm "$i"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment