How to Use SwiftFormat with SweetPad

Published under Mango Snippets, Feb 10, 2025

SweetPad is a VS Code extension for Swift/iOS development, with swift-format formatting built in. However, I prefer using SwiftFormat by Nick Lockwood for its comprehensive formatting options.

To use SwiftFormat with SweetPad, update the formatter path and remove the default --in-place argument in VS Code settings:

Sweetpad's formatter settings in VS Code

Here's my settings.json:

{
    "[swift]": {
        "editor.formatOnSave": true,
        "files.autoSaveWorkspaceFilesOnly": true,
        "editor.defaultFormatter": "sweetpad.sweetpad"
    },
    "sweetpad.format.args": [
        "${file}"
    ],
    "sweetpad.format.path": "swiftformat"
}