第九块石头

使用Uncrustify让iOS代码更漂亮

| Comments

Github project: uncrustify-config-ios

uncrustify config for iOS developer

What is it

Uncrustify make code format beautiful. It needs configrations, I couldn’t find a good configuration for iOS developer on Objective-C.

Here’s a repo collecting pretty uncrustify config for iOS developer.

You can distribute your configurations over pull request.

Requirements

  1. Tested with Xcode 4.6+ (also works in Xcode 5) on OS X 10.7 or higher.
  2. Uncrustify 0.60 higher (0.60 has a bug for Objective-C block, so install master HEAD or higher in the future)
  3. BBUncrustifyPlugin-Xcode

Installation

  1. using HomeBrew install Uncrustify
1
brew install uncrustify --HEARD
1
git clone https://github.com/dijkst/uncrustify-config-ios.git ~/.uncrustify

Example

align code:

before:

1
2
3
NSString *const BBUncrustifyOptionEvictCommentInsertion = @"evictCommentInsertion";
NSString *const BBUncrustifyOptionSourceFilename = @"sourceFilename";
NSString *const BBUncrustifyOptionSupplementalConfigurationFolders = @"supplementalConfigurationFolders";

after:

1
2
3
NSString *const BBUncrustifyOptionEvictCommentInsertion            = @"evictCommentInsertion";
NSString *const BBUncrustifyOptionSourceFilename                   = @"sourceFilename";
NSString *const BBUncrustifyOptionSupplementalConfigurationFolders = @"supplementalConfigurationFolders";

remove space:

before:

1
-( void )viewWillEnter ;

after:

1
- (void)viewWillEnter;

insert newline between methods

1
2
3
4
- (void)a {
}
- (void)b{
}

after:

1
2
3
4
5
- (void)a {
}

- (void)b {
}

and so on.

License

uncrustify-config-ios is available under the MIT license.

Comments

comments powered by Disqus