Is any way to autoformat a source code in the Xcode IDE?
ClangFormat-Xcode is an Xcode plugin available in Alcatraz. This is a nice code format tool.
I found that the Copy & Paste method (Cmd-A then Cmd-C then Cmd-V) worked in XCode 4 and was the method I used whilst I was waiting for google to display the results (Mac was going slow!)
There isn't really an autoformat option in Xcode.
There is an option ^I
(Control-I) to re-indent the code, which will re-align the code according to the tab width set in your preferences, but that's about as far as it goes.
You might have better luck with a text editor like TextMate? I don't know for certain, but I know it supports Objective-C and has some macros, there may be a reformat option?
To change, go to xCode => Preferences => Text Editing => Indentation => Automatically indent based on syntax.
enter link description here
For anyone wanting to format on save this is what I did. It's a bit janky but it works well. ⤵
CMD + ~
CMD + S
for Xcode and set it to actually use your shortcut you set for your fomatter. Like this ⤵
One trick is to select the code (either "select all" or just the section you want to re-format) - then cut, then paste it back. This triggers the automatic code formatting in the Xcode editor.