Skip to content

Instantly share code, notes, and snippets.

@youngshook
Created March 14, 2014 08:19
Show Gist options
  • Save youngshook/9543935 to your computer and use it in GitHub Desktop.
Save youngshook/9543935 to your computer and use it in GitHub Desktop.
Find unused images in an XCode project
#!/bin/sh
# -------
# Usage sh unusedImages.sh (jpg|png|gif)
# -------
# Caveat
# 1 -
# NSString *imageName = [NSString stringWithFormat:@"image_%d.png", 1];
# This script would incorrectly list these images as unreferenced. For example, you might have
# This script will incorrectly think image_1.png is unreferenced.
# 2 - If you have a method, or variable with the same name as the image it won't pick it up
 
PROJ=`find . -name '*.xib' -o -name '*.[mh]' -o -name '*.storyboard' -o -name '*.plist'`
 
for imageName in `find . -name '*.'$1`
do
name=`basename -s .$1 $imageName`
name=`basename -s @2x $name`
name=`basename -s ~ipad $name`
name=`basename -s @iPad $name`
 
if ! grep -q $name $PROJ; then
echo "$imageName"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment