Swift Plugin for the Opinionated Code Formatter
What does it do?
You can check out how it formatted Artsy's Eidolon.
Prerequisites
You need one of the following:
- A snapshot from March 30, 2018 or later,
- a recent manual build from Swift's
master, or - Swift 4.2 (once it's available as a beta or released completely).
Assuming you picked (1) please follow the
installation instructions,
which recommend updating your PATH at the end:
TOOLCHAIN=swift-DEVELOPMENT-SNAPSHOT-2018-03-30-a.xctoolchain
export PATH=/Library/Developer/Toolchains/${TOOLCHAIN}/usr/bin/:"${PATH}"
Alternatively you can pass the full path to the swiftc binary
via the environment variable PRETTIER_SWIFT_SWIFTC:
TOOLCHAIN=swift-DEVELOPMENT-SNAPSHOT-2018-03-30-a.xctoolchain
export PRETTIER_SWIFT_SWIFTC=/Library/Developer/Toolchains/${TOOLCHAIN}/usr/bin/swiftc
Contributing
If you're interested in contributing to the development of Prettier for Swift, you can follow the CONTRIBUTING guide from Prettier, as it all applies to this repository too.
To test it out on a Swift file:
- Clone this repository.
- Run
yarn. - Create a file called
test.swift. - Run
yarn prettier test.swiftto check the output.
Install
yarn add --dev --exact prettier prettier/plugin-swiftUse
prettier --write "**/*.swift"Maintainers
Marcel Jackwerth |

