11 May
Geek's corner

Xcode 4 and Uncrustify

Sometimes IT developers, especially working in one team, become dissatisfied with each other. Sometimes it even causes injuries. Frequently the good way to soothe the pain and to fill the working atmosphere with pleasantness and goodwill is to accept some Coding style rules. That’s the time when good utils come in hand. We use Uncrustify for automatic code formatting here.

As some of you could notice Apple dropped out Xcode scripting support from Xcode 4. It wasn’t a nice move for me because I have implemented tons of automation through it, and the most valuable task I used to solve with it was automagic sourcecode formatting with Uncrustify.

It was a really simple script like this:

echo -n "%%%{PBXSelection}%%%"
/usr/bin/env uncrustify -l OC -q -c ~/.uncrustify.cfg
echo -n "%%%{PBXSelection}%%%"

And it doesn't work anymore since Apple’s move. After a day and a night of sufferings, I finally saw a glimmer of hope. There is solution for Xcode 4 through the Customer Service of Hell Automator Services.

The most pretty implementation I found at Tony Arnold’s github page: Xcode-4-Uncrustify-Automator-Services. It has detailed installation instructions which you can follow easily. And don’t forget to copy or make symlink for your “uncrustify.cfg” file into “~/.uncrustify.cfg”.

Thank you, Tony!

And also there is our free-to-download uncrustify config for concerned ones: here it is.

Recent entries