Install swift-format:
brew install swift-format
Create a .swift-format
using this template.
curl -s https://raw.githubusercontent.com/BinaryBirds/swift-format-template/main/.swift-format > .swift-format
Add these lines to your Makefile
:
format:
swift-format -i -r ./Sources && swift-format -i -r ./Tests
lint:
swift-format lint -r ./Sources && swift-format lint -r ./Tests
One-liner integration:
curl -s https://raw.githubusercontent.com/BinaryBirds/swift-format-template/main/.swift-format > .swift-format && curl -s https://raw.githubusercontent.com/BinaryBirds/swift-format-template/main/Makefile >> ./Makefile
Usage:
make format
make lint
That's it.