# Improvements to Swift in Visual Studio Code coming with Swift 6

**URL:** <https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708>\
**Category:** VSCode Swift extension\
**Created:** [June 24, 2024, 1:53pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708 "2024-06-24T13:53:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [June 24, 2024, 1:53pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/1 "2024-06-24T13:53:18Z")

</div>

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.

## Testing

Along with existing support for XCTest, Swift for VS Code now has integration with [swift-testing](http://github.com/apple/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.

 ![VSCode-swift-testing](https://global.discourse-cdn.com/swift/original/3X/f/6/f6889576850130fa9837e1f9e47762910e608969.png)

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.

 ![VSCode-Coverage](https://global.discourse-cdn.com/swift/original/3X/f/c/fc333c847c2cc5fb2e414737c6981a8614ebee71.png)

## 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](http://github.com/apple/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](https://github.com/vadimcn/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](https://swiftlang.github.io/swiftly/).

 ![VSCode-select-toolchain](https://global.discourse-cdn.com/swift/original/3X/7/8/7812aedc92ad26917dd497dbcf64431eecf8da3f.png)

## 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](https://github.com/apple/sourcekit-lsp/blob/main/Documentation/Enable%20Experimental%20Background%20Indexing.md) 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.

---

<div class="post-metadata">

**Author:** ![ole](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ole/32/18720_2.png) [@ole](https://forums.swift.org/u/ole)\
**Post date:** [June 24, 2024, 4:02pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/2 "2024-06-24T16:02:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [June 24, 2024, 4:12pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/3 "2024-06-24T16:12:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joshw](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joshw/32/34626_2.png) [@joshw](https://forums.swift.org/u/joshw)\
**Post date:** [June 24, 2024, 5:33pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/4 "2024-06-24T17:33:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![WildCat](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/wildcat/32/9374_2.png) [@WildCat](https://forums.swift.org/u/WildCat)\
**Post date:** [June 24, 2024, 6:15pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/5 "2024-06-24T18:15:58Z")

</div>

Thanks for sharing this! Dumb question: Where could we download this extension? Is it [Swift - Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang) by SSWG?

---

<div class="post-metadata">

**Author:** ![kebo](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kebo/32/6918_2.png) [@kebo](https://forums.swift.org/u/kebo)\
**Post date:** [June 24, 2024, 6:17pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/6 "2024-06-24T18:17:03Z")

</div>

> On Linux the list will include a list of toolchains installed using [Swiftly](https://swift-server.github.io/swiftly/).

Swiftly's link is broken. I believe it is now [swiftly - A Swift toolchain installer and manager, written in Swift](https://swiftlang.github.io/swiftly/) because the repository has been moved to the new swiftlang org.

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [June 24, 2024, 6:46pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/7 "2024-06-24T18:46:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [June 24, 2024, 6:47pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/8 "2024-06-24T18:47:52Z")

</div>

Fixed. Thanks for pointing that out.

---

<div class="post-metadata">

**Author:** ![wwwalkerrun](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/wwwalkerrun/32/36099_2.png) [@wwwalkerrun](https://forums.swift.org/u/wwwalkerrun)\
**Post date:** [June 24, 2024, 7:20pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/9 "2024-06-24T19:20:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xtremekforever](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xtremekforever/32/43018_2.png) [@xtremekforever](https://forums.swift.org/u/xtremekforever)\
**Post date:** [June 24, 2024, 9:56pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/10 "2024-06-24T21:56:24Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ktoso](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ktoso/32/44526_2.png) [@ktoso](https://forums.swift.org/u/ktoso)\
**Post date:** [June 24, 2024, 10:48pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/11 "2024-06-24T22:48:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![t089](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/t089/32/40449_2.png) [@t089](https://forums.swift.org/u/t089)\
**Post date:** [June 25, 2024, 7:06am UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/12 "2024-06-25T07:06:12Z")

</div>

Great news indeed! Thanks for the hard work 💪

---

<div class="post-metadata">

**Author:** ![Joannis\_Orlandos](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joannis_orlandos/32/732_2.png) [@Joannis\_Orlandos](https://forums.swift.org/u/Joannis_Orlandos)\
**Post date:** [June 25, 2024, 1:33pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/13 "2024-06-25T13:33:21Z")

</div>

Amazing work as always

---

<div class="post-metadata">

**Author:** ![Datagram](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@Datagram](https://forums.swift.org/u/Datagram)\
**Post date:** [June 25, 2024, 2:36pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/14 "2024-06-25T14:36:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [June 25, 2024, 2:38pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/15 "2024-06-25T14:38:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Datagram](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@Datagram](https://forums.swift.org/u/Datagram)\
**Post date:** [June 25, 2024, 2:55pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/16 "2024-06-25T14:55:58Z")

</div>

> [@adam-fowler](#):
>
> nightly build

Tested with latest nightly build on Windows 11.

[compnerd.org](http://compnerd.org) 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%

---

<div class="post-metadata">

**Author:** ![dave256](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dave256/32/37106_2.png) [@dave256](https://forums.swift.org/u/dave256)\
**Post date:** [June 25, 2024, 4:08pm UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/17 "2024-06-25T16:08:13Z")

</div>

@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](https://forums.swift.org/t/vs-code-wont-run-swift-on-windows/72721)

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).

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![BrentM](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/brentm/32/15134_2.png) [@BrentM](https://forums.swift.org/u/BrentM)\
**Post date:** [June 27, 2024, 1:26am UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/18 "2024-06-27T01:26:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![LightningDesigner](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lightningdesigner/32/36139_2.png) [@LightningDesigner](https://forums.swift.org/u/LightningDesigner)\
**Post date:** [June 27, 2024, 10:55am UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/19 "2024-06-27T10:55:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adam-fowler](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/adam-fowler/32/9266_2.png) [@adam-fowler](https://forums.swift.org/u/adam-fowler)\
**Post date:** [June 27, 2024, 11:43am UTC](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708/20 "2024-06-27T11:43:52Z")

</div>

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 [swift.org](http://swift.org)

[Next page](https://forums.swift.org/t/improvements-to-swift-in-visual-studio-code-coming-with-swift-6/72708.md?page=2)
