Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding unused files in Xcode

Tags:

xcode

ios

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?

like image 937
JDx Avatar asked Jan 31 '13 17:01

JDx


People also ask

How to remove unused images from Xcode project?

To verify this, select a few random sample images. Then search for them in the Xcode project and make sure they are not used. Then select the delete command and fly them all.

Where are unused images in Xcode project?

Use http://jeffhodnett.github.io/Unused/ to find the unused images.

How do I remove unused codes in Swift?

The integration steps are very easy; you have to create a new dedicated target, and among its build phases add the command that launches Periphery: periphery scan . Then when you'll run the project Periphery will start scanning the app reporting as many warnings as unused code found.


2 Answers

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.

like image 154
WDUK Avatar answered Oct 18 '22 18:10

WDUK


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.

like image 11
Wilmar Avatar answered Oct 18 '22 20:10

Wilmar