Improvements to Swift in Visual Studio Code coming with Swift 6

Aligned with Swift 6, Swift in Visual Studio Code (VS Code) is gaining a number of new features and improvements. Some of these features come with the Swift 6 version of SourceKit-LSP, which provides intelligent editor functionality to all editors that support the Language Server Protocol (LSP), including VS Code. Others are related to new functionality coming with Swift 6, or custom additions to the VS Code extension itself.


Along with existing support for XCTest, Swift for VS Code now has integration with swift-testing. Both types of tests appear in the VS Code Test Explorer and can be run, debugged, or run with code coverage. The swift-testing integration supports all the equivalent features from XCTest and some swift-testing specific features like custom test names, and test parameters.

In addition SourceKit-LSP now provides custom support for test discovery. Test locations are available as soon as your project has loaded into VS Code.

Code coverage

Recently VS Code introduced a framework for running code coverage tests and rendering the results. We have replaced the custom implementation we used previously with an integration with the new framework. Now coverage results are rendered in a pane included in the TestExplorer view.

Symbol rename

The new rename feature in SourceKit-LSP allows functions, types, variables, etc. to be renamed workspace-wide. It is fully aware of Swift-specific rename patterns like functions with argument labels and also allows cross-language rename of symbols shared with other languages through Swift’s C, C++, and Objective-C interop. Rename integrates into the standard VS Code rename workflow, such as the refactor preview window and can be invoked using Rename Symbol from the command palette or context menu.

Integration with swift-format

SourceKit-LSP integrates with swift-format to apply formatting to your source code. Formatting is available using Format Document from the command palette. It uses a default formatting style which can be customized by placing a .swift-format file in the root of your project.

Debug adapter

Up until this point we have been reliant on the CodeLLDB extension debug adapter to provide debugging support for Swift in VS Code. The Swift 6 toolchain comes with it's own LLDB debug adapter (lldb-dap). The extension has support for choosing between these two debug adapters.

Toolchain selection

You can select the Swift toolchain you are working with using the Swift: Select Toolchain... command. This provides options to select a toolchain directory or select from a platform specific list of toolchains available to you. On macOS you will get a list of toolchains attached to Xcode installs, and installed Swift nightly snapshots. On Linux the list will include a list of toolchains installed using Swiftly.

Background indexing of SwiftPM projects

SourceKit-LSP gained the ability to index SwiftPM projects in the background, which means that you no longer have to build the project to update the index and get cross-module functionality to work. Background indexing is currently available as an experimental feature. This guide describes how to enable it, if you are interested.

Check it out

On macOS you can check out all of the above by either downloading the latest Xcode 16 beta and selecting the Xcode beta toolchain using the new Select Toolchain... command from the command palette in VS Code or you can test inside a devcontainer, setup with the latest Swift 6 nightly docker image. On Linux and Windows you can download the latest Swift 6 nightly.


Those are fantastic changes. @adam-fowler Thank you so much for all your work on the extension!


Thank you, but I can't claim responsibility for all of those changes. A small development team at Apple have been helping out and many of these features were implemented by them.


HUGE upgrades! I think the work being done on Swift for VSCode will be a huge driver of swift on the server adoption. Great work @adam-fowler and Apple squad.


Thanks for sharing this! Dumb question: Where could we download this extension? Is it Swift - Visual Studio Marketplace by SSWG?

1 Like

On Linux the list will include a list of toolchains installed using Swiftly .

Swiftly's link is broken. I believe it is now swiftly - A Swift toolchain installer and manager, written in Swift because the repository has been moved to the new swiftlang org.

Yes. You can also download it from inside VS Code. Just search for Swift in the extensions view. The SSWG extension should come up first.

1 Like

Fixed. Thanks for pointing that out.

1 Like

Thank you for the incredible work here @adam-fowler and entire team behind these updates! We really enjoy Xcode but also love to work in VS Code and improving Swift interop in VS Code allows our teams to work better with Swift across diverse projects.


These are awesome! We have been using Swift 6.0 already to leverage the fancy new features of swift-testing and having these available in VSCode makes the development experience quite lovely. Definitely an exciting future in store for Swift!


Fantastic updates! I’m so excited about the progress here and making vscode great for daily development :slight_smile:


Great news indeed! Thanks for the hard work :muscle:


Amazing work as always


Thank you for all this excellent progress!

Does anyone have a status on an upcoming fix regarding the CPU usage (25%+) of sourcekit-lsp.exe in VSCode on Windows?

Have you tested this with a recent Swift 6 nightly build, I'm pretty sure I've seen Issues resolved related to Windows performance.

1 Like

Tested with latest nightly build on Windows 11. Swift version 6.0-dev (LLVM 57177aa1b91540b, Swift 6debc331289f02d)

VSCode 1.90.2 with Swift extension v1.10.3

sourcekit-lsp.exe CPU usage constantly at min 25%

@adam-fowler Thanks to you and everyone else who worked on this. I'm trying to get Swift working in VS Code on Windows for my students. We've tried on one of their computers but have been unsuccessful. Some more details here: VS Code won't run Swift on Windows

I'm happy to try the Swift 6 toolchain. Are you saying if we download and run that .exe to install the Swift 6 toolchain, use VS Code and install the Swift extension for VS-Code we can now have it use lldb-dap and it will work without CodeLLDB (which seems not to work for us when we tried it).


Now if only we could do iOS development in VSCode! Loving all these changes. Swift's tooling outside of macOS is getting better by the day.

I hope some day, we will be able to use Swift UI or other swift libraries on VS code or windowss

It has been pointed out that the toolchain that comes with Xcode beta 2, does not have all the changes required for the background indexing. So if you want to test that out and be sure you are running with the most up to date version of the toolchain you should download a 6.0 nightly from