views:

1926

answers:

4

I'm a newbie on Objective-C programming and aiming to follow Google's code convention: http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml.

Some code formatting tool would be handy to use, is there any Objective-C code formatter that can easily be integrated into XCode?

A: 

A partial answer is that some little things can be set from within Xcode, as 2-space indents. See Indentation Preferences in Xcode Workspace Guide.

mouviciel
+1  A: 

Reportedly, bcpp works just fine on obj-c, and it has a TextMate plugin, too.

Matt Kane
+3  A: 

XCode has a code formatter built in - it's a little basic but can re-indent your code. First set your indentation preferences in Xcode (as mouviciel suggests). Then select the source you want to reintend and choose Edit | Format | Re-indent.

If you want to go further, Hackertoys has instructions for adding uncrustify support to Xcode. I have not tried this.

Roger Nolan
+1  A: 

After tinkering with multiple external formatters and the weak internal xcode formatter, I finally settled with uncrustify. Uncrustify has fairly good Objective-C support, can easily be integrated with xcode as a user script, and provides a centralized formatter for pretty much all languages that xcode natively supports.

The biggest hurdle with xcode is the daunting configuration file. My recommendation, take one of the supplied sample configs (ben2.cfg is very good), merge in the objc.cfg sample, and tweak as necessary.

rcw3