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?
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.
Use http://jeffhodnett.github.io/Unused/ to find the unused images.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With