Text

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

Tags: xcode4 objc
Text

Changing Xcode 4’s default code snippets

Xcode 4 brought along a code snippets feature that is actually useful. Nearly as useful as TextMate snippets but not quite as powerful. One of the most annoying things though is that Xcode bundles in a bunch of default snippets that you can neither edit nor remove in Xcode.

With a little snooping around it’s pretty easy to find how to update these or get rid of them so you can have your code looking the way you like again.

Is what you’re looking for. It’s a .plist and pretty straight forward. I tend to back up the System one and symlink my own from a Dropbox directory for all my replacements.

Note you shouldn’t remove this file though just empty it out if you’re looking to get rid of all the snippets.

-Robert