apple 公式のフォーマッターである swift-format の使いかた。
インストール
% git clone -b swift-5.2-branch https://github.com/apple/swift-format.git
% cd swift-format
% swift build
以下のエラーが出る場合
xcrun: error: unable to find utility "xctest", not a developer tool or in PATH
以下で直る
% sudo xcode-select --reset
以下で実行
(ディレクトリは各自のxcodeのプロジェクトのディレクトリを指定する)
% swift run swift-format -r /Volumes/hoge/Documents/project -i