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 288 forks source link

The Info.plist should specify a principal class (TRVSClangFormat). #72

Closed masonmark closed 9 years ago

masonmark commented 9 years ago

The ClangFormat-Info.plist file should specify the principal class as TRVSClangFormat. This would help people who fork it to hack on it to avoid the case that Xcode seemingly-randomly silently fails to load the plug-in.

If the principal class is not specified, then the plug-in bundle load process will just use whatever class it first encounters as the principal class. But if somebody working on a fork adds a new class to the project in the usual way within Xcode, it has a high chance of being added to the Compile Sources build phase before the TRVSClangFormat class.

If that happens, then the plugin will build fine, but Xcode will just silently fail to load it (because whatever class was selected as the principal class does not implement the required plug-in interface).

In the Xcode build settings editor for the target "ClangFormat", in the Info tab, the plist contents are shown in human-readable form. Using this editor, you can add a value to the list for "Principal class" and set it to "TRVSClangFormat".

This will have the effect of adding the following to the ClangFormat-Info.plist file (and hence the built bundle's Info.plist file):

<key>NSPrincipalClass</key>
<string>TRVSClangFormat</string>

Once that is done, forkers can add classes to the project willy-nilly, without affecting the Xcode plugin load process.