A way to automatically organize #imports in Xcode

后端 未结 9 1583
眼角桃花
眼角桃花 2021-01-30 20:38

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 X

相关标签:
9条回答
  • 2021-01-30 21:00

    I made a small Xcode plugin to sort the headers and remove duplicates of the file with a shortcut, you can check it out! - https://github.com/insanoid/CleanHeaders-Xcode

    0 讨论(0)
  • 2021-01-30 21:02

    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 !

    0 讨论(0)
  • 2021-01-30 21:03

    Swiftlint has an opt-in rule which if opted, will automatically sort the imports alphabetically.

    Add - sorted_imports to your .swiftlint.yml file under opt_in_rules.

    Run swiftlint autocorrect terminal command on project root directory (same where swiftlint.yml is stored).

    0 讨论(0)
  • 2021-01-30 21:04

    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

    0 讨论(0)
  • 2021-01-30 21:09

    WordService (freeware) from Devon Technologies, provides a service that can be used in any Cocoa app that can (amongst others) sort lines.

    0 讨论(0)
  • 2021-01-30 21:10

    AppCode from Jetbrains can do this.

    0 讨论(0)
提交回复
热议问题