Working in Xcode I almost forgot how much I like IntelliJ’s code formatting tools. Luckily for me Mike Smith recently pointed out that UniversalIndentGUI can be used to setup your own code formatting in Xcode.
UniversalIndentGUI supports a large number of code formatting tools but Uncrustify seems to be the only one with objective-c support. An up to date build of Uncrustify (version 0.53) is included with UniversalIndentGUI so I did not need to build my own.
I setup a set of styling rules using UniversalIndentGUI’s live preview and saved the resulting config file. I was then able to add a set of custom user scripts in Xcode to run Uncrustify against the current file or selection. I found that I had to specify the source as objective-c to prevent Uncrustify form running some C/C++ styling rules which I did not want.
Now I can quickly clean up most of the minor formatting inconsistencies which creep into my code. Now I just need to polish my config file until it better matches my expectations for code formatting. In defining my preferred code style I have tried to follow the example provided by: