A way to automatically organize #imports in Xcode

Viewed 14148

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?

9 Answers

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).

Related