travisjeffery / ClangFormat-Xcode

Xcode plug-in to to use clang-format from in Xcode and consistently format your code with Clang
https://twitter.com/travisjeffery
MIT License
2.89k stars 287 forks source link

Enforce ClangFormat Rules #15

Closed grevolution closed 10 years ago

grevolution commented 10 years ago

Hi,

is there a way to enforce the ClangFormat rules on a file during compilation? or during a commit? like uncrustify-pre-commit

tonyarnold commented 10 years ago

There is, but is there a reason why you can't just turn on format on save?

grevolution commented 10 years ago

just as an extra precaution if some developer (working in teams) forgets to use the option format on save.

tonyarnold commented 10 years ago

You can edit your Xcode Scheme to add a Pre or Post Build action — just run clang-format manually using a script on all of your files. It's going to be a bit clunky though.

You could certainly also add a pre-commit script that calls clang-format manually (although you'd probably want to install clang-format via homebrew — it's in the llvm package, I believe).

grevolution commented 10 years ago

sure, i'll try that. thank you :+1: