Xcode — finding dead methods in a project

北城余情 提交于 2019-12-05 06:51:37

Using static analysis, it is impossible to detect functions/methods that are defined but not used due to dynamic nature of Objective-C. The only reasonable solution is to run a coverage using GCov or similar tool. Even then, you will have to make your program do everything possible in order to make sure that you do not strip out some feature that was just not used during testing.

Also, this script has some interesting thoughts on this.

Given the very verbose but descriptive method names often chosen in Objective-C programs, I find that doing a textual Find In Project is usually sufficient. I will usually just use the first part of a method name so as to avoid having to match method arguments. This will match normal method calls and use of @selector and NSSelectorFromString.

Of course, this won't work for very common method names or if you need the rest of the method name to disambiguate between many similar methods, but I find that to be a rare occurrence.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!