Archive

Posts Tagged ‘ios’

How to remove unused images from Xcode Project

December 17, 2012 Leave a comment

Most of the times we include many png files in our project and then forget to delete those which are never referenced in our project. You may use following script to find out unsed images in an iOS project

For files which are not referenced neither in xib nor in code, something like this might work:


#!/bin/sh
PROJ=`find . -name '*.xib' -o -name '*.[mh]'`

for png in `find . -name '*.png'`
do
    name=`basename $png`
    if ! grep -q $name $PROJ; then
        echo "$png is not referenced"
    fi
done

 

You need to save the above script in a file(let’s say ‘myscript’ ) and then follow the below procedure to execute it

  • Go to your Xcode project root folder
  • type “sh myscript”

It’s done. on your screen you will see all the png files which are not referenced in your code.

Note: Beware it will also list the png files which are not referenced in your xib or .m file but are referenced from your sqlite database so make sure you dont delete them.

 

Advertisements
Categories: iOS Tags: , , ,