A way to automatically organize #imports in Xcode

2019-03-08 14:57发布

I love the "Organize Imports" command in Eclipse to implicitly add and remove classes imported into a source file (as in Java or ActionScript).

Is there a command in Xcode to update the #import directives at the top of.m Objective-C files based on the classes referenced within the file?

8条回答
Explosion°爆炸
2楼-- · 2019-03-08 15:45

Yup. Like in Eclipse, this would be an awesome feature since developing in XCode (Cocoa Touch) does require quite a bit of class imports which are not easy to remember and Android development in Eclipse sorts this out with a simple keystroke combination that saves so much time ! Hope there is a way to do this in XCode soon !

查看更多
唯我独甜
3楼-- · 2019-03-08 15:50

I've found Cedar Shortcuts to at least be usable. It's not as good as Eclipse's import feature (it doesn't organize imports), but it can keep you from having to go to the top of a class file and typing an import statement. With this plugin you just place the cursor on the class that needs imported and press Ctrl + Option + I. Here's the github project. https://github.com/cppforlife/CedarShortcuts

查看更多
登录 后发表回答