Skip to content

poplax/clangformatter-extension

 
 

Repository files navigation

Clang Format Code-Style-Format

A code style-format tool for Xcode Source Editor Extension.

You can create your own (or team) code style configuration.

Learn from here

Objective-C(only)

Requirement

  • OS X 10.12 or higher
  • Xcode 9.x+

Install

  1. Download ClangFormatter.app
  2. Copy and Open ClangFormatter.app to /Applications Folder.
  3. Run it then close it.

OR

curl -SL https://gist.githubusercontent.com/poplax/c0898b6127a5747bcc1316c2a7ede58e/raw/59339589cae4eacf590fc1ca8dc2cb8bafc330c8/Install-xcode-format-tool | sh

Uninstall

Delete ClangFormatter.app from /Applications

Usage

1. Enable ClangFormat

Check System Preferences -> Extensions -> Xocde Source Editor -> ClangFormat

Start(or restart) The Xcode.

2. Setting Shortcut in Xcode

Preferences -> Key bindings -> Filter: clangformat

3. Use Menu (or key bindings) to format your Objective-C file. (Xcode)

Editor -> ClangFormat -> ObjC-Format

Custom Your Own Style

Change options of the _clang-format-objc file.

See ClangFormat-Option

Update Your config file.

Step 1,2 is Optional

  • First, Move to your config file(_clang-format-objc) Folder.

In Project:

cd ClangFormat/style-config/

  • Copy the config file to the format app.
cp -f ./_clang-format-objc /Applications/ClangFormatter.app/Contents/PlugIns/ClangFormat.appex/Contents/Resources/_clang-format-objc

TODO List

  1. Modify the config file(_clang-format-objc) of the user interface

  2. Other clang-style config file:

    • C/C++
    • Java
    • JavaScript

Reference

License

MIT