Introduction
Another year, another holiday project.
This year, I really wanted to focus on what I consider to be one of the main issues with Swift: the lack of tooling on non-Apple platforms. In particular, I wanted to improve the developer experience for students using Visual Studio Code on Linux or Windows.
To that end, it seemed logical to build a new extension for Visual Studio Code, something which I have previously done for Stencil.
Features
Fortunately, I didn't have to start from scratch. Visual Studio Code relies on the Language Server Protocol, for which Apple already has an open source implementation: SourceKit-LSP.
The following features are already provided by SourceKit-LSP:
- Code completion
- Quick help on hover
- Inline diagnostics and fix-its
- Jump to definition
- Find references
Additionally, Visual Studio Code includes a TextMate grammar for Swift, so syntax highlighting is provided as well.
With all of these features already covered, the new extension should focus on implementing missing features, such as:
- Building, running, and debugging Swift packages
- Testing and code coverage
- Managing package dependencies
Implementation
After familiarizing myself with TypeScript and the Visual Studio Code Extension API, I quickly got to work on building the extension. A few weeks later, I had a working prototype with two main features:
- Automatic creation of build tasks
- A package dependencies view
I showed this prototype to members of the Swift Server Workgroup, who expressed interest in further developing it as an official Visual Studio Code extension for Swift, published by the workgroup. Shortly after I made my first commits, Adam Fowler from the workgroup joined the effort, took over leadership, and make the extension into what it is today.
Even though I only had a few weeks of spare time to commit to this project, I am nevertheless proud of having started something that has significantly improved the developer experience of Swift on Linux and Windows.
For more information, see the useful links below.