-
Install clang-format:
$ brew install clang-format
-
Place
.clang-format
file under your project. -
In Xcode, open
Product
>Scheme
>Edit Scheme...
>Build
>Pre-actions
. -
Click
+
button and select your target (Provide build settings from
). -
Copy and paste this shell script:
5-A. If you are using git (recomended):
cd $SRCROOT && git status --porcelain \ | awk '$1 ~ /^[MA]/ && $2 ~ /\.(cpp|hpp)$/ {print $2}' \ | xargs /opt/homebrew/bin/clang-format -i -style=file
Now your project files ends with
.cpp
or.hpp
where git status is "added" or "modified" will be formatted on build.5-B. Otherwise:
find -E ${PROJECT_DIR} -regex ".*\.(cpp|hpp)" | xargs /opt/homebrew/bin/clang-format -i -style=file
Now your project files ends with
.cpp
or.hpp
will be formatted on build.
-
Notifications
You must be signed in to change notification settings - Fork 0
Instruction on how to clang-format on build in Xcode
License
Lfu001/clang-format-Xcode
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Instruction on how to clang-format on build in Xcode