Is there a way to specify or remove useless imports in an .m Objective-C file

is there any way to automatically specify or remove useless imports in an .m file of Objective-C?

For example, a .m file:

#import "Ah" #import "Bh" #import "Ch" 

But Bh in my .m file will never be used, is there a way to automatically specify or delete it, just like the AppCode IDE.

+5
source share
4 answers

Check out here: Find Unused Objective-C Import

Use the following:

Finding unused classes in a path

 fui --path=~/source/project/Name find 

Delete all unused class files with the command

 fui --path=~/source/project/Name delete --perform --prompt 

You can also use the Xcode plugin to do this:

Use xcfui to integrate with XCode from here: https://github.com/jcavar/xcfui

Script to find unused imports:

https://gist.github.com/Orangenhain/7691314

+3
source

As already mentioned, there is no official Xcode tool, but you can do it with other tools (e.g. Fui )

0
source

http://www.jetbrains.com/objc/ has a code check function that finds unused import and code.

0
source

Remove the double import from your project, run this script https://github.com/Brsoyan/Unused-import-for-Objective-C This works well. You can set the prefix of the file you need to find. If you need to remove unused categories, import chanage remove_categories = True

-1
source

All Articles