GithubHelp home page GithubHelp logo

classicvalues / xcodeclangformat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/xcodeclangformat

0.0 1.0 0.0 663 KB

Format code in Xcode 8+ with clang-format

License: Other

Objective-C 35.47% Objective-C++ 64.13% C 0.40%

xcodeclangformat's Introduction

XcodeClangFormat

Uses clang-format from Clang 10

...or install with Homebrew: brew cask install xcodeclangformat

This plugin is written for Xcode 8's new plugin infrastructure and compatible through at least Xcode 11.4 It uses Clang's libclangFormat library to format code according to a .clang-format file.

Open the app, select a predefined style, or open the .clang-format file from your project:

Then, use the Format Source Code command in Xcode's Editor menu:

Due to macOS sandboxing restrictions, this plugin behaves slightly differently compared to the command line clang-format command: It always uses the style selected in the configuration app, and will not use the nearest .clang-format file on disk.

Installing

Download the precompiled app or build it yourself, then open the app. You might have to right click on the app bundle, and choose Open to run non-codesigned applications. Then,

  • On OS X 10.11, you'll need to run sudo /usr/libexec/xpccachectl, then reboot to enable app extensions.
  • On macOS Sierra and later, extensions should be loaded by default.

Then, go to System PreferencesExtensions, and make sure that clang-format in the Xcode Source Editor section is checked:

Keyboard shortcut

To define a keyboard shortcut, open Xcode's preferences, and switch to the Key Bindings tab. Duplicate the default key binding set if you don't have your own set already. Search for clang-format, then add your preferred key bindings for Format Selection or Format Entire File.

Building

To build XcodeClangFormat, run ./configure on the command line, then build the XcodeClangFormat scheme in the included Xcode project.

FAQ

Why aren't you just using the .clang-format file in the file's parent folder?

Xcode code formatting extensions are severely limited and don't have access to the file system. They also don't get to know the file name of the file to be changed, so there's no way for this extension to load the correct file.

Could you please add “Format on Save”?

The Xcode extension mechanism doesn't allow that; the only thing you can do is return the altered source code.

Why doesn't the menu item show up?

If you're using macOS Sierra, please follow the installing guide. on OS X 10.11, I haven't found a way to make this extension work besides manually building it.

If the menu items randomly disappears, quit Xcode. In Finder, rename Xcode.app to something else, then rename it back to Xcode.app. 🤯

When compiling, I'm getting 'clang/Format/Format.h' file not found.

Make sure that you're running ./configure in the root folder. This downloads and unpacks the precompiled libraries and headers from the llvm.org that are required for compiling.

xcodeclangformat's People

Contributors

kkaefer avatar rggjan avatar scoopr avatar 1ec5 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.