5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Objective-C のソースコードをフォーマット

Posted at

以前は uncrustify を使っていた。

最近は clang-format というものがあるようだ。

$ brew install clang-format

A.m をフォーマットするには

$ clang-format -i A.m

.m, .h, .c をフォーマット

$ find . \( -name "*.m" -or -name "*.h" -or -name "*.c" \) -exec $(clang-format) -i \{\} \;

-style オプションでプリセットスタイルを指定したり、設定ファイルで細かく指定したりできるみたい。

$ clang-format -h
<snip>
  -dump-config              - Dump configuration options to stdout and exit.
                              Can be used with -style option.
<snip>
  -style=<string>           - Coding style, currently supports:
                                LLVM, Google, Chromium, Mozilla, WebKit.
                              Use -style=file to load style configuration from
                              .clang-format file located in one of the parent
                              directories of the source file (or current
                              directory for stdin).
                              Use -style="{key: value, ...}" to set specific
                              parameters, e.g.:
                                -style="{BasedOnStyle: llvm, IndentWidth: 8}"
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?