SwiftFormat is a code library and command-line tool for reformatting Swift code on macOS or Linux. SwiftFormat goes above and beyond what you might expect from a code formatter. In addition to adjusting white space, it can insert or remove implicit self, remove redundant parentheses, and correct many other deviations from the standard Swift idioms. Many programmers have a preferred style for formatting their code, and others seem entirely blind to the existing formatting conventions of a project. When collaborating on a project, it can be helpful to agree on a common coding style, but enforcing that manually is tedious and error-prone, and can lead to arguments if some participants take it more seriously than others. Having a tool to automatically enforce a common style eliminates those issues, and lets you focus on the behavior of the code, not its presentation.

Features

  • Use as a command-line tool that you run manually, or as part of some other toolchain
  • Use as a Source Editor Extension that you can invoke via the Editor > SwiftFormat menu within Xcode
  • Use as a build phase in your Xcode project, so that it runs every time you press Cmd-R or Cmd-B
  • Use as a Git pre-commit hook, so that it runs on any files you've changed before you check them in
  • Like the command-line tool, you can install the SwiftFormat for Xcode extension application via Homebrew
  • SwiftFormat's configuration is split between rules and options

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow SwiftFormat

SwiftFormat Web Site

You Might Also Like
Build Securely on Azure with Proven Frameworks Icon
Build Securely on Azure with Proven Frameworks

Lay a foundation for success with Tested Reference Architectures developed by Fortinet’s experts. Learn more in this white paper.

Moving to the cloud brings new challenges. How can you manage a larger attack surface while ensuring great network performance? Turn to Fortinet’s Tested Reference Architectures, blueprints for designing and securing cloud environments built by cybersecurity experts. Learn more and explore use cases in this white paper.
Download Now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of SwiftFormat!

Additional Project Details

Operating Systems

Linux, Mac

Programming Language

Swift

Related Categories

Swift Terminals, Swift Command Line Tools, Swift Code Formatters

Registered

2021-10-14