Visual Studio Code Extension for Swift
1,068
stars
1,351
commits
TypeScript
primary language
Sep 10, 2026
updated
This extension adds language support for Swift to Visual Studio Code, providing a seamless experience for developing Swift applications on all supported platforms. It supports features such as:
Note
Most features of the Swift for Visual Studio Code extension only work with projects that build with Swift Package Manager. These projects will have aPackage.swiftfile in their root folder. Support for Xcode projects (.xcodeproj) is limited.
The getting started guide and official documentation for this extension are available on swift.org.
This extension uses SourceKit LSP for the language server, which powers code completion. It also has a dependency on the LLDB DAP extension to enable debugging.
To propose new features, you can post on the swift.org forums in the VS Code Swift Extension category. If you run into something that doesn't work the way you'd expect, you can file an issue in the GitHub repository.
The Swift extension exports a comprehensive API that can be used by other Visual Studio Code extensions. The API provides access to:
The API includes a version number that follows semantic versioning and is separate from the extension's version number. See the contributing guide for a more detailed explanation on when this version number is incremented.
To use the API in your extension you can download the src/SwiftExtensionApi.ts file from this repository to get proper TypeScript type definitions. It is recommended that you download the version from a tagged release as main is not guaranteed to remain stable.
Example usage:
import { getSwiftExtensionApi, SwiftExtensionApi } from './SwiftExtensionApi';
// Get the Swift extension API
const api: SwiftExtensionApi = await getSwiftExtensionApi();
// Access workspace context
const workspaceContext = api.workspaceContext;
if (workspaceContext) {
// Get the toolchain version
const toolchain = workspaceContext.globalToolchain;
console.log(`Using Swift ${toolchain.swiftVersion}`);
// Listen for folder changes
workspaceContext.onDidChangeFolders((event) => {
console.log(`Folder operation: ${event.operation}`);
});
// Access the in focus folder and its Swift package
const currentFolder = workspaceContext.currentFolder;
if (currentFolder) {
const swiftPackage = currentFolder.swiftPackage;
const targets = await swiftPackage.targets;
console.log(`Found ${targets.length} targets`);
}
}
The Swift for Visual Studio Code extension is based on an extension originally created by the Swift Server Working Group. It is now maintained as part of the swiftlang organization, and the original extension is deprecated. Contributions, including code, tests, and documentation, are welcome. For more details, refer to CONTRIBUTING.md.
To provide clarity on the expectations for our members, Swift has adopted the code of conduct outlined in the Contributor Covenant. This widely recognized document effectively encapsulates our values. For more information, please refer to the Code of Conduct.
(top 30 of 53)
TypeScript
97.4%
Swift
1.0%
Visual Studio Code Extension for Swift
1,068
stars
1,351
commits
TypeScript
primary language
Sep 10, 2026
updated
This extension adds language support for Swift to Visual Studio Code, providing a seamless experience for developing Swift applications on all supported platforms. It supports features such as:
Note
Most features of the Swift for Visual Studio Code extension only work with projects that build with Swift Package Manager. These projects will have aPackage.swiftfile in their root folder. Support for Xcode projects (.xcodeproj) is limited.
The getting started guide and official documentation for this extension are available on swift.org.
This extension uses SourceKit LSP for the language server, which powers code completion. It also has a dependency on the LLDB DAP extension to enable debugging.
To propose new features, you can post on the swift.org forums in the VS Code Swift Extension category. If you run into something that doesn't work the way you'd expect, you can file an issue in the GitHub repository.
The Swift extension exports a comprehensive API that can be used by other Visual Studio Code extensions. The API provides access to:
The API includes a version number that follows semantic versioning and is separate from the extension's version number. See the contributing guide for a more detailed explanation on when this version number is incremented.
To use the API in your extension you can download the src/SwiftExtensionApi.ts file from this repository to get proper TypeScript type definitions. It is recommended that you download the version from a tagged release as main is not guaranteed to remain stable.
Example usage:
import { getSwiftExtensionApi, SwiftExtensionApi } from './SwiftExtensionApi';
// Get the Swift extension API
const api: SwiftExtensionApi = await getSwiftExtensionApi();
// Access workspace context
const workspaceContext = api.workspaceContext;
if (workspaceContext) {
// Get the toolchain version
const toolchain = workspaceContext.globalToolchain;
console.log(`Using Swift ${toolchain.swiftVersion}`);
// Listen for folder changes
workspaceContext.onDidChangeFolders((event) => {
console.log(`Folder operation: ${event.operation}`);
});
// Access the in focus folder and its Swift package
const currentFolder = workspaceContext.currentFolder;
if (currentFolder) {
const swiftPackage = currentFolder.swiftPackage;
const targets = await swiftPackage.targets;
console.log(`Found ${targets.length} targets`);
}
}
The Swift for Visual Studio Code extension is based on an extension originally created by the Swift Server Working Group. It is now maintained as part of the swiftlang organization, and the original extension is deprecated. Contributions, including code, tests, and documentation, are welcome. For more details, refer to CONTRIBUTING.md.
To provide clarity on the expectations for our members, Swift has adopted the code of conduct outlined in the Contributor Covenant. This widely recognized document effectively encapsulates our values. For more information, please refer to the Code of Conduct.
(top 30 of 53)
TypeScript
97.4%
Swift
1.0%