Using Uncrustify directly in Xcode 4!
One of the biggest problems I have using 3rd party libraries is that they’re formatted horribly and there’s not many great code formatters around that can do Objective-C, C, C++ all in one go. Luckily Uncrustify can but it’s not exactly the easiest to configure or get running easily. With the help of a small ruby script and a little time exploring the preferences in Xcode you can set up Uncrustify to scan your project’s directory for all .h, .m, .c, .mm files and format them at the whim of your keyboard. You’ll need two files stored somewhere on your drive. I put them in /usr/local/etc/.
Shell Script:
Uncrustify Config:
Xcode Behavior:
With both of these stored on your hard drive it’s as easy as going into Xcode’s preferences and adding a behaviour on the behaviour tab. Here’s what mine looks like:

Remember to customise the uncrstufiy config as you see fit!
-Robert