46

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 ?

Community
  • 1
  • 1
Fengson
  • 4,751
  • 8
  • 37
  • 62

5 Answers5

76

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.

David Lari
  • 943
  • 11
  • 21
12

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

Vinoth Anandan
  • 1,157
  • 17
  • 15
8

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

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

Anindya
  • 351
  • 6
  • 7
2

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

Keshu R.
  • 5,045
  • 1
  • 18
  • 38
1

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

wzso
  • 3,482
  • 5
  • 27
  • 48