You can do this by creating an Automator action and using it in Xcode, as well as everywhere in Mac OS X. To do this, follow these steps:
- Launch Automator โ New
- Select "Service"
- add action "run shell script"
- use
sort | uniq sort | uniq as a script and check the box "output replaces the selected text" - save and give it a name (for example, "sort and unique")
- check "Exit replaces selected text"
After you save it, you can simply select your import in Xcode, right-click and select your "sort and unique" action to organize the import.
This is not as good as organizing import operations in Eclipse or IntelliJ, because it does not remove unused things, etc., but it is better than nothing.
PS: Got it from WWDC 2012 sessions - Session 402 Works efficiently with Xcode (starting at 6:15)
EDIT
I started using the AppCode, an Objective-C IDE from JetBrains, and it has features like "organize imports." You should check this out: http://www.jetbrains.com/objc/ .
Tim Bรผthe Jun 24 2018-12-12T00: 00Z
source share