I am using xcode 9 with objective c. And i want to remove unused variable and methods from classes. I am also use this way but xcode do not warning of unused methods etc. How to find out?
Those who are looking for a way to remove unused code from Swift project, it can be done easily using Periphery. Periphery is a tool to remove unused code from Swift projects. It can detect unused function, struct, class, protocols etc.
Replies. In Xcode, select the app name on the top left/resources, then on the right choose 'build phases', then expand 'copy bundle resources', then find those images by name, select them, scroll down and tap '-' below to remove the references.
xcutility is a tool to find and delete unused files from Xcode projects. It recursively searches through a path to find all of the path's Xcode projects and files, and will tell you which files are not referenced or built in any of your Xcode projects.
Unfortunately unlike C functions, getting a list of unused objc methods in the form of warnings in Xcode is tricky due to the dynamic runtime environment. Your code might, for example,create a selector from a string and then call that selector on a class or instance of one etc.
One approach I've used, however it's time consuming depending on the size of the class(es), is to open the assistant editor and position the cursor over the method you wish to inspect and select callers (see below image. Normally the default selection is counterparts).
If there are no callers of the method then the editor shows no results.
However if you do this be aware no results will also show for IBActions and overrides in subclasses of iOS frameworks etc. You need to really know the code to determine if 'no results' really means no callers!
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