14

Is there a config file for Uncrustify that will format Objective-C per Google's Objective-C style guide?

Example config files for Uncrustify look a bit daunting and I'm hoping that I won't need to build one from scratch...

a paid nerd
  • 30,702
  • 30
  • 134
  • 179

2 Answers2

7

I wanted to incorporate uncrustify into my automated builds but faced problems. I found an alternative that I'm happy with. The AppCode objective-C IDE from Jetbrains works as a supplemental IDE to Xcode.

It includes an excellent and highly configurable code formatting tool, among other things.

enter image description here

. . . to my knowledge you can't invoke this tool from the cmd-line, however I've just filed a feature request to do so.

If you prefer Uncrustify there's a GUI Tool that might help.

Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
  • Great find, it is much easier to see what will happen when the code gets re-formatted this way. The preview area (visible at the right in the screenshot) shows the effect of each option when checked or unchecked. – Form Jan 26 '13 at 20:55
  • 2
    Since I answered that there's also uncrusifyX https://github.com/ryanmaxwell/UncrustifyX – Jasper Blues Jan 27 '13 at 00:38
  • It should be noted that while AppCode has reformatting capability, it doesn't have a 'Google Style' profile built in. I can't see any way of generic import/export of profiles. The default is also almost useless in that it does virtually nothing. You have to go in and make quite a few changes (lots of tedious experimentation) before you get much useful happening. – Roger Binns Apr 22 '13 at 04:04
  • You're right - I could see a save option, but nothing about importing. . I've raised a feature request with Jetbrains. – Jasper Blues Apr 22 '13 at 04:41
  • I think the .idea/codeStyleSettings.xml file may be helpful here. – Benjamin Cox Apr 04 '14 at 21:45
2

That config file seems daunting only in length... (I've seen much worse!) I don't know if it conforms to the Google style guide, but mmorris posted his .cfg in this answer: https://stackoverflow.com/a/7321776/18961

You don't want to strictly conform to the Google style anyway... it only uses two character indentation! ;)

Community
  • 1
  • 1
livingtech
  • 3,570
  • 29
  • 42
  • 1
    4 char indents are insane, especially for posting code on the web! 2 should more than suffice IMHO. –  Mar 21 '12 at 20:13