To maintain a consistent code style across the Untold Engine repo, we use SwiftFormat. SwiftFormat is a code formatter for Swift that helps enforce Swift style conventions and keep the codebase clean.
The simplest way to install SwiftFormat is through the command line.
- Install SwiftFormat Using Homebrew: Open the terminal and run the following command:
brew install swiftformat
- Verify Installation: After installation, verify that SwiftFormat is installed correctly by running:
swiftformat --version
This should print the installed version of SwiftFormat.
Format a Single File
To format a specific Swift file:
-
Open the terminal and navigate to your project directory.
-
Run the following command:
swiftformat path/to/YourFile.swift
This will format YourFile.swift according to the default rules.
To format all Swift files in your project:
-
Navigate to your project directory in the terminal.
-
Run the following command:
swiftformat .
This will recursively format all Swift files in the current directory and its subdirectories.