Fengson
Fengson

Reputation: 4912

How to find unused code in Xcode 7?

I have seen this question, but the answer doesn't seem to be valid in Xcode 7. At least I can't find it.

Can anyone tell me where can I tell the compiler to notify me about unused functions/parameters/values ?

Upvotes: 47

Views: 31238

Answers (5)

Keshu R.
Keshu R.

Reputation: 5225

2022 Update | Swift

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.

Its very easy to use. You can get step by step guide here :

Remove Unsed Code from iOS Swift Project

Upvotes: 2

wzso
wzso

Reputation: 3885

For those who are seeking a solution for Objective-C codebase like me, try this script by @nst. It analyzes the mach-o files.

Upvotes: 1

Anindya
Anindya

Reputation: 351

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

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

Upvotes: 8

Vinoth Anandan
Vinoth Anandan

Reputation: 1287

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

Upvotes: 14

user4151918
user4151918

Reputation:

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.

Upvotes: 79

Related Questions