Skip to content

Commit

Permalink
Updated for 0.43.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Dec 18, 2019
1 parent 9cbe433 commit b564570
Show file tree
Hide file tree
Showing 30 changed files with 80 additions and 47 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,14 @@
# Change Log

## [0.43.0](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.43.0) (2019-12-18)

- Added per-line warning when running in `--lint` mode
- Significantly improved Xcode integration when running as a build step in `--lint` mode
- Added `--lenient` option to suppress errors when running in `--lint` mode
- Fixed bug where required `self` was sometimes incorrectly removed inside a trailing closure
- Improved `wrap` rule heuristic for prioritizing where a line should be broken
- Fixed bug in `typeSugar` rule affecting namespaced types

## [0.42.0](https://github.com/nicklockwood/SwiftFormat/releases/tag/0.42.0) (2019-11-30)

- Added `wrap` rule for automatic wrapping of long statements or expressions based on `--maxwidth` option
Expand Down
Binary file modified CommandLineTool/swiftformat
Binary file not shown.
2 changes: 1 addition & 1 deletion EditorExtension/Application/Info.plist
Expand Up @@ -32,7 +32,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.42.0</string>
<string>0.43.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion EditorExtension/Extension/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>0.42.0</string>
<string>0.43.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSMinimumSystemVersion</key>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions EditorExtension/SwiftFormat for Xcode.app/Contents/Info.plist
Expand Up @@ -32,7 +32,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.42.0</string>
<string>0.43.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand All @@ -42,17 +42,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>11B500</string>
<string>11C29</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>19B89</string>
<string>19B90</string>
<key>DTSDKName</key>
<string>macosx10.15</string>
<key>DTXcode</key>
<string>1120</string>
<string>1130</string>
<key>DTXcodeBuild</key>
<string>11B500</string>
<string>11C29</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>NSHumanReadableCopyright</key>
Expand Down
Binary file not shown.
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>0.42.0</string>
<string>0.43.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand All @@ -27,17 +27,17 @@
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>11B500</string>
<string>11C29</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>19B89</string>
<string>19B90</string>
<key>DTSDKName</key>
<string>macosx10.15</string>
<key>DTXcode</key>
<string>1120</string>
<string>1130</string>
<key>DTXcodeBuild</key>
<string>11B500</string>
<string>11C29</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>NSExtension</key>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Expand Up @@ -6,27 +6,27 @@
<dict>
<key>Resources/Base.lproj/Main.storyboardc/9ZR-Qg-hHT-view-iDF-FY-6tf.nib</key>
<data>
wAW+8ygQ6vNPY3flmHSOpBpJOU0=
pmldPJZ9SetNi4ugjvPzvsnVevI=
</data>
<key>Resources/Base.lproj/Main.storyboardc/Info.plist</key>
<data>
KekjDtIGuLc4Tia14mfhTy3bSj0=
X9Tov1TU3cvmNUqerSATXjeoos8=
</data>
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
<data>
yhcNGu55eve6R74+TZLA1+6MSSA=
5PFjD95csDIEvNQ88N5+ZUqdNLs=
</data>
<key>Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib</key>
<data>
zWBiXA8MEFqlkhVFNV90egsyIsA=
VnczjlCU/SQSj04eWgFTYXjyVUY=
</data>
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
<data>
BFG/IrO7AYsOKUp3L3YbXPdoGA8=
+i3kezXF0mmqOdnsGASsFKzL2Qg=
</data>
<key>Resources/Base.lproj/Main.storyboardc/RulesViewController.nib</key>
<data>
IcMYHpqhzqQJ+rQQbEZ5ARQQkyA=
7ntcMdYIWqH6ZQ3Rj4V5mMZ5MRw=
</data>
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
<data>
Expand Down Expand Up @@ -111,7 +111,7 @@
<dict>
<key>cdhash</key>
<data>
o6H7/FFzDjpdGADI7kukOes6Xj4=
pD1M05k5rwfTHG7LRxR7X+1VzL0=
</data>
<key>requirement</key>
<string>identifier "com.charcoaldesign.SwiftFormat-for-Xcode.SourceEditorExtension" and anchor apple generic and certificate leaf[subject.CN] = "Mac Developer: Nick Lockwood (XDQ4XJZXHD)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
Expand All @@ -120,66 +120,66 @@
<dict>
<key>hash</key>
<data>
wAW+8ygQ6vNPY3flmHSOpBpJOU0=
pmldPJZ9SetNi4ugjvPzvsnVevI=
</data>
<key>hash2</key>
<data>
o+IdPqIA9P9k+/L5q53szVIjn9NqD4DjzPKDGpBttFQ=
L3EdYRN47luSBXd4e+iI6C8Si5K/mzgPk0uzwNOKvss=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/Info.plist</key>
<dict>
<key>hash</key>
<data>
KekjDtIGuLc4Tia14mfhTy3bSj0=
X9Tov1TU3cvmNUqerSATXjeoos8=
</data>
<key>hash2</key>
<data>
vtNpZEbh8zFW9nmznrdoVgQF8jqD1mJ3LXIgNK7JQRc=
cuBZCq+6XaIEkoZDGtMXyo2x8rIwsJ/kauIyo5ZhLoI=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
<dict>
<key>hash</key>
<data>
yhcNGu55eve6R74+TZLA1+6MSSA=
5PFjD95csDIEvNQ88N5+ZUqdNLs=
</data>
<key>hash2</key>
<data>
+XHyyE2I76pOQT/+QUy5K+b1xcMxapki6+/0NQOPqdw=
7VVdlioqCgJocUBr/9C7A6mrhWgHixfQDxd+N/cPIU0=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/MainWindowTabViewController.nib</key>
<dict>
<key>hash</key>
<data>
zWBiXA8MEFqlkhVFNV90egsyIsA=
VnczjlCU/SQSj04eWgFTYXjyVUY=
</data>
<key>hash2</key>
<data>
5iwaiMDdVgUefmIypLrWw3gN7O8aDpM7aKoUuun/vTs=
8gcaJrVm/vAeMUK7CIvUrXBlLTP3bwePXiiGdflt+Eg=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/NSWindowController-B8D-0N-5wS.nib</key>
<dict>
<key>hash</key>
<data>
BFG/IrO7AYsOKUp3L3YbXPdoGA8=
+i3kezXF0mmqOdnsGASsFKzL2Qg=
</data>
<key>hash2</key>
<data>
YlJQmDZL0ceKTECJxt1pzrcjpgcUVLsnsRz/xe+5Fr0=
8w/nM90jiFcW6tQHVEcZjyn5vGaoDjETJ2rUeI00XiE=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/RulesViewController.nib</key>
<dict>
<key>hash</key>
<data>
IcMYHpqhzqQJ+rQQbEZ5ARQQkyA=
7ntcMdYIWqH6ZQ3Rj4V5mMZ5MRw=
</data>
<key>hash2</key>
<data>
oWv4KpRvt6nTWO+9r7DsezT5zqbGmxRbmA1JANWb+xw=
Nm6sk7xl/QWiedqSZpquTFVGJsHm+LNhoBXNx6brUEw=
</data>
</dict>
<key>Resources/Base.lproj/Main.storyboardc/XfG-lQ-9wD-view-m2S-Jp-Qdl.nib</key>
Expand Down
42 changes: 33 additions & 9 deletions README.md
Expand Up @@ -51,7 +51,7 @@ Having a tool to automatically enforce a common style eliminates those issues, a
How do I install it?
---------------------

That depends. There are four ways you can use SwiftFormat:
That depends - There are several ways you can use SwiftFormat:

1. As a command-line tool that you run manually, or as part of some other toolchain
2. As a Source Editor Extension that you can invoke via the Editor > SwiftFormat menu within Xcode
Expand Down Expand Up @@ -178,12 +178,17 @@ The format of the configuration file is described in the [Config section](#confi

Xcode build phase
-------------------

**NOTE:** Adding this script will overwrite your source files as you work on them, which has the annoying side-effect of clearing the undo history. You may wish to add the script to your test target rather than your main target, so that it is invoked only when you run the unit tests, and not every time you build the app.

Alternatively, you might want to consider running SwiftFormat in [lint](#linting) mode as part of your normal build, and then running a formatting pass manually, or as part of a less-frequent build target (such as the tests).

### Using Swift Package Manager

To set up SwiftFormat as an Xcode build phase, do the following:

#### 1) Create a BuildTools folder & Package.swift

1. Create a folder called `BuildTools` in the same folder as your xcodeproj file
2. In this folder, create a file called `Package.swift`, with the following contents:
```swift
Expand All @@ -199,7 +204,8 @@ let package = Package(
)
```

#### 2) Add Build phases to your app target
#### 2) Add a Build phases to your app target

1. Click on your project in the file list, choose your target under `TARGETS`, click the `Build Phases` tab
2. Add a `New Run Script Phase` by clicking the little plus icon in the top left
3. Drag the new `Run Script` phase **above** the `Compile Sources` phase, expand it and paste the following script:
Expand All @@ -209,23 +215,32 @@ let package = Package(
swift run -c release swiftformat "$SRCROOT"
```

NOTE: You may wish to check BuildTools/Package.swift into your source control so that the version used by your run-script phase is kept in version control. It is recommended to add the following to your .gitignore file: `BuildTools/.build` and `BuildTools/.swiftpm`.
**NOTE:** You may wish to check BuildTools/Package.swift into your source control so that the version used by your run-script phase is kept in version control. It is recommended to add the following to your .gitignore file: `BuildTools/.build` and `BuildTools/.swiftpm`.


### Using Cocoapods

#### 1) Add the SwitfFormat CLI to your Podfile

1. Add the `swiftformat` binary to your project directory via [CocoaPods](https://cocoapods.org/), by adding the following line to your Podfile then running `pod install`:

```ruby
pod 'SwiftFormat/CLI'
```
**NOTE:** This will only install the pre-built command-line app, not the source code for the SwiftFormat framework.

2. In the Build Phases section of your project target, add a new Run Script phase before the Compile Sources step:
**NOTE:** This will only install the pre-built command-line app, not the source code for the SwiftFormat framework.

#### 2) Add a Build phase to your app target

1. Click on your project in the file list, choose your target under `TARGETS`, click the `Build Phases` tab
2. Add a `New Run Script Phase` by clicking the little plus icon in the top left
3. Drag the new `Run Script` phase **above** the `Compile Sources` phase, expand it and paste the following script:
```bash
"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat"
"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat" "$SRCROOT"
```

### Alternative: Locally installed swiftformat

Alternatively, you could use a locally installed swiftformat command-line tool instead by putting the following in your Run Script build phase:

```bash
Expand Down Expand Up @@ -497,11 +512,19 @@ In order to run SwiftFormat as a linter, you can use the `--lint` command-line o
$ swiftformat --lint path/to/project
```

This works exactly the same way as when running in format mode, and all the same configuration options apply, however no files will be modified. SwiftFormat will simply format each file in memory and then compare the result against the input and report the files that required changes.
This runs the same rules as format mode, and all the same configuration options apply, however no files will be modified. Instead, SwiftFormat will format each file in memory and then compare the result against the input and report the lines that required changes.

The `--lint` option is similar to `--dryrun`, but `--lint` returns warnings for every line that required changes, and will return a nonzero error code if any changes are detected, which is useful if you want it to fail a build step on your CI server.

If you would prefer `--lint` not to fail your build, you can use the `--lenient` option to force SwiftFormat to return success in `--lint` mode even when formatting issues were detected.

```bash
$ swiftformat --lint --lenient path/to/project
```

The `--lint` option is very similar to `--dryrun`, except that `--lint` will return a nonzero error code if any changes are detected, which is useful if you want it to fail a build step on your CI server.
By default, `--lint` will only report lines that require formatting, but you can use the additional `--verbose` flag to display additional info about which files were checked, even if there were no changes needed.

By default, `--lint` will only report the number of files that were changed, but you can use the additional `--verbose` flag to display a detailed report about which specific rules were applied to which specific files.
If you would prefer not to see a warning for each and every formatting change, you can use the `--quiet` flag to suppress all output except errors.


Cache
Expand Down Expand Up @@ -662,6 +685,7 @@ Credits
* [Ali Akhtarzada](https://github.com/aliak00) - Several path-related CLI enhancements
* [Yonas Kolb](https://github.com/yonaskolb) - Swift Package Manager integration
* [Wolfgang Lutz](https://github.com/Lutzifer) - AppleScript integration instructions
* [Balázs Kilvády](https://github.com/balitm) - Xcode lint warning integration
* [Nick Lockwood](https://github.com/nicklockwood) - Everything else

([Full list of contributors](https://github.com/nicklockwood/SwiftFormat/graphs/contributors))
2 changes: 1 addition & 1 deletion Sources/Formatter.swift
Expand Up @@ -2,7 +2,7 @@
// Formatter.swift
// SwiftFormat
//
// Version 0.42.0
// Version 0.43.0
//
// Created by Nick Lockwood on 12/08/2016.
// Copyright 2016 Nick Lockwood
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.42.0</string>
<string>0.43.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftFormat.swift
Expand Up @@ -32,7 +32,7 @@
import Foundation

/// The current SwiftFormat version
public let version = "0.42.0"
public let version = "0.43.0"

/// The standard SwiftFormat config file name
public let swiftFormatConfigurationFile = ".swiftformat"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Tokenizer.swift
Expand Up @@ -2,7 +2,7 @@
// Tokenizer.swift
// SwiftFormat
//
// Version 0.42.0
// Version 0.43.0
//
// Created by Nick Lockwood on 11/08/2016.
// Copyright 2016 Nick Lockwood
Expand Down
4 changes: 2 additions & 2 deletions SwiftFormat.podspec.json
@@ -1,6 +1,6 @@
{
"name": "SwiftFormat",
"version": "0.42.0",
"version": "0.43.0",
"license": {
"type": "MIT",
"file": "LICENSE.md"
Expand All @@ -10,7 +10,7 @@
"authors": "Nick Lockwood",
"source": {
"git": "https://github.com/nicklockwood/SwiftFormat.git",
"tag": "0.42.0"
"tag": "0.43.0"
},
"default_subspecs": "Core",
"subspecs": [
Expand Down
2 changes: 1 addition & 1 deletion Tests/Info.plist
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.42.0</string>
<string>0.43.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit b564570

Please sign in to comment.