Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find unused code in Xcode 7?

People also ask

How do you find the dead code?

The quickest way to find dead code is to use a good IDE. Delete unused code and unneeded files. In the case of an unnecessary class, Inline Class or Collapse Hierarchy can be applied if a subclass or superclass is used. To remove unneeded parameters, use Remove Parameter.

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.

Which tool can be used to identify dead code?

Since dead code detection is a delicate process that requires absolute certainty of the deadness status, developers should only use a tool specifically designed to read source code to find the unused parts. Project Analyzer is such a tool.


Xcode has a number of settings you can enable to warn you about things like unused functions, parameters, and values.

enter image description here

You can also easily enable strict warnings by setting your Other Warning Flags to -Wall -Wextra -Weverything.

Another option for detecting unused code is by using Code Coverage.


In left side select Project and in Build Settings

Unused functions, parameters, and values

Unused functions, parameters, and values

Other Warning Flags to -Wall -Wextra -Weverything

Other Warning Flags to -Wall -Wextra -Weverything


To check the unused functions and variables you can also use the following scripts-

https://github.com/PaulTaykalo/swift-scripts