JDx JDx - 1 year ago 93
iOS Question

Finding unused files in Xcode

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 stuff that isn't needed.

I'm wondering, is there any way to tell which class files are being used in Xcode? Or any tips on how to find unused files?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download