Skip to content

Swift setup

Here is how to set up Swift in VS Code with mise:

  1. Install the mise-vscode extension (if not already installed)
  2. Install the Swift extension for VS Code
  3. Open a project with a mise.toml file (or any other files supported by mise)

If your project has a mise.toml file, such as the one below:

[tools]
swift = "latest"

mise-vscode will automatically detect it and set swift.path in your workspace settings.

If you want to quickly initialize a Swift project, you can use the following commands:

  1. mkdir my-swift-project && cd my-swift-project
  2. mise use swift@latest
  3. swift package init

This will create a new Swift project with a mise.toml file that specifies the latest version of Swift. Once the mise-vscode extension has initialized the extension SDK paths, the Swift VS Code extension should work.

Changing the Swift path requires Visual Studio Code be reloaded.

Section titled “Changing the Swift path requires Visual Studio Code be reloaded.”

This warning may display on launch when not using symlinks. While the Swift extension still works despite the warning, it can be silenced by enabling symlinks:

{
"mise.configureExtensionsUseSymLinks": true
}

The Swift Extension has detected a change in the selected Xcode which does not match the value of your “swift.path” setting.

Section titled “The Swift Extension has detected a change in the selected Xcode which does not match the value of your “swift.path” setting.”

On macOS the Swift VS Code extension looks for the XCode developer directory. You can silence this warning by setting the value of the DEVELOPER_DIR environment variable to the output of xcode-select -p in your VS Code settings. While this could be set in your workspace settings it’s generally better to set it in your user settings as it may vary between systems and environments.

xcode-select -p
# /Applications/Xcode.app/Contents/Developer
{
"swift.swiftEnvironmentVariables": {
"DEVELOPER_DIR": "/Applications/Xcode.app/Contents/Developer"
}
}