I\'ve recently started work on a new app which is basically a copy of a previous app I made, with a few changes. To make this new app I\'ve copied the old app and removed some s
There isn't any functionality like this built into Xcode, but the issue of unused classes/files etc isn't as simple as one may think.
People have created scripts to try and determine unused files. I have used the script located here, which searches through all your source files, and tries to pair up the resource files. The script also tries to check for source files not included within your project.
The reason its not so trivial is that Obj-C is a very dynamic language; a lot of things are determined at run-time. As such, it sometimes can be tricky to figure out unused files statically. For example, an image name might be determined on the fly depending on user input.
I don't know how big your application is, but you could try a dependency graph, and check for orphan classes. See this blog post on some more information.
See the useful tool. A Mac app for checking Xcode projects for unused resources http://jeffhodnett.github.io/Unused/
There's an app called Slender by Martiancraft that is good for suggesting potentially unused images.
http://martiancraft.com/products/slender.html
I believe that Faux Pas does something similar for class files, but I will check. That app does also look for unused methods, translations and resources.
http://fauxpasapp.com/rules/#rule-UnusedResource
I haven't used either app recently, but can remember being impressed with both previously.
Also see this shell scripts http://mfaizanshaikh.wordpress.com/2012/12/17/how-to-remove-unused-images-from-xcode-project/
Basically the shell script below, finds all the png
files in your project that are not used in any of the xib
files. Of course if you have used the png
file in other ways (storyboards, load in the code), this script will still show them as unused.
for reference I paste the scripts here as well:
#!/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
This tool finds unused imports/classes: fui.
From the README page:
Find unused Objective-C imports.
The AppCode IDE from Jetbrains has some very decent code inspection functions. It can point out unused classes and other resources, and claims to be fully Xcode compatible.