如何在 Xcode 7 中找到未使用的代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35233564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:30:25  来源:igfitidea点击:

How to find unused code in Xcode 7?

iosxcodedebugging

提问by Fengson

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

我见过这个问题,但答案在 Xcode 7 中似乎无效。至少我找不到。

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

谁能告诉我在哪里可以告诉编译器通知我未使用的函数/参数/值?

回答by

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

Xcode 有许多设置,您可以启用它们来警告您有关未使用的函数、参数和值等内容。

enter image description here

在此处输入图片说明

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

你也可以很容易地通过您设置启用严格的警告等警示标志-Wall -Wextra -Weverything

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

检测未使用代码的另一种选择是使用 Code Coverage

回答by Vinoth Anandan

In left side select Projectand in Build Settings

在左侧选择ProjectBuild Settings

Unused functions, parameters, and values

未使用的函数、参数和值

Unused functions, parameters, and values

未使用的函数、参数和值

Other Warning Flags to -Wall -Wextra -Weverything

-Wall -Wextra -Weverything 的其他警告标志

Other Warning Flags to -Wall -Wextra -Weverything

-Wall -Wextra -Weverything 的其他警告标志

回答by Anindya

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

要检查未使用的函数和变量,您还可以使用以下脚本-

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

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