Skip to content

Instantly share code, notes, and snippets.

@elmoswelt
Forked from vibrazy/unusedImages.sh
Created July 29, 2012 16:10
Show Gist options
  • Save elmoswelt/3199938 to your computer and use it in GitHub Desktop.
Save elmoswelt/3199938 to your computer and use it in GitHub Desktop.
How to 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