Adam Fowler is an open source developer and is a member of the SSWG (Swift Server Workgroup).

As Swift is deployed across more platforms, it is important that Swift can be developed on more platforms as well. The Swift Extension for Visual Studio Code provides a cross-platform solution for Swift development supporting macOS, Linux, and Windows.

Motivation

Swift is held back from extending outside the Apple ecosystem by the lack of a first-class, integrated development environment on non-Apple platforms. There is no Xcode if you are developing on Linux or Windows.

Until this point there have been individual components to make up that development environment like Apple’s SourceKit-LSP project and support for the Swift version of LLDB when using the CodeLLDB extension, but nothing to bring them all together.

The Swift Server Workgroup (SSWG) felt there was a need for a more complete solution. The Swift Extension for Visual Studio Code from the SSWG brings together many of these components into one package with everything pre-configured to work from the get-go.

Features

The extension is primarily targeted at Swift Packager Manager (SwiftPM) projects. It consists of a number of components already available as well as new ones, all brought together into one coherent package.

Pre-configured Development Environment

Visual Studio Code uses a number of JSON configuration files to set up your development environment. The Swift extension will auto-generate these files for your SwiftPM project so you won’t need to manually set them up. When you load a project, the extension creates build tasks for everything in your project, along with debug and release versions for any executables in your Package.swift. It will also create debugger launch configurations for debug and release builds of all executables.

Package Dependencies View

The extension provides a package dependency view that shows a list of all your package dependencies along with the versions you are using. The view can be expanded so you can inspect the contents of each dependency. A right-click menu allows you to view the repository for that package as well as replace the dependency with a version local to your computer. Buttons in the title bar add resolve, update, and reset actions for your package.

SourceKit-LSP integration

The language server protocol (LSP) is a standard for providing language features such as symbol completion and jump-to-definition in source code editors like Visual Studio Code. Swift support is available to LSP-compatible editors via Apple’s SourceKit-LSP implementation. The Swift extension manages the running of a SourceKit-LSP server to provide these language features for Swift and C/C++ source files.

Debugger

A debugger is provided via the CodeLLDB debugger extension. All the hard work integrating with LLDB is done by CodeLLDB. The Swift extension provides the integration with CodeLLDB by creating debug launch configurations for your project executables on start up. It also configures CodeLLDB to use the Swift version of LLDB.

Test Explorer

The Test Explorer provides a UI similar to the Xcode Tests UI. The UI contains a tree view, including all the test targets, with each XCTestCase class contained within those targets and each individual test contained within those classes. Tests can be run outside of a debugger or in the debugger. You can run individual tests, or filter the tests being run by class or test target, or just run all tests. The UI updates as tests succeed or fail.