views:

197

answers:

4

Checkstyle is a great tool to enforce a code standards for java. We have some projects working with objective-c, and I tried to find some similar tool like checkstyle for Objective-C, but didn't get lucky.

Does anyone know that kind of tool which be used to enforce code standards for Objective-C? Thanks in advance.

A: 

I'm not farmiliar with Checkstyle. But x-code comes built in with a static code analyzer.

If you're using xCode 3.2 and above in the build menu you can just select build & analyze, and it will give you the results in the build results.

Ron Srebro
Matt Chen
A: 

Not familiar with Checkstyle, but Clang is a good static analyzer for obj-c.

taskinoor
A: 

Try BCPP or uncrustify. Depending on how you want to use the tool (command line or within an editor), you should be able to find documentation specific to your environment.

(The usual tool for C programs is indent, but it doesn't support Obj-C.)

0x4b
Thank you for your comment. Actually I don't want a code formatter or code beautifier tool, I need a tool like checkstyle in Java, which I can set a code standards defined by ourself, and run I this tool on our code, it'll check code and tell which code is not meet the code standards. :-)
Matt Chen
+1  A: 

Try using uncrustify and the Universal Indent GUI.

To get you started here is the URL to my uncrustify config file http://polymicro.net/files/uncrustify.cfg

Place it in your home folder and rename to .uncrustify.cfg

Also, try adding these code snips to your Xcode user scripts:

Uncrustify Selection

#!/bin/sh
cat << EOFEOFEOF | /usr/local/bin/uncrustify -q  -c ~/.uncrustify.cfg
%%%{PBXSelectedText}%%%
EOFEOFEOF

Uncrustify File

#!/bin/sh
uncrustify -q -f "%%%{PBXFilePath}%%%"
tgunr