After reading Mattt's excellent NSHipster article on building the fledgling Swift Language Server Protocol project, I scrolled back up and stared at Step 0: Install Xcode. It didn't seem strictly necessary, based on what followed. And as I’m sure you’ve deduced by the title and existence of this post, it’s not. Below is a short step-by-step guide to building and running the Swift Language Server Protocol on linux1. The following instructions assume either a basic understanding of a unix-style command line and/or a willingness to copy and paste superuser commands from the internet into your terminal program of choice.

  1. Install VS Code by following these instructions:
  2. Make sure that you have all the necessary dependencies installed:
    $ sudo apt install curl git clang libsqlite3-dev libblocksruntime-dev libncurses5-dev
  3. Download the recommended Swift development toolchain from or via the command line:
    $ curl > ~/swift-DEVELOPMENT-SNAPSHOT-2018-12-07-a-ubuntu18.04.tar.gz
  4. Extract the toolchain and move it to /usr/local/bin:
    $ sudo tar xzf swift-DEVELOPMENT-SNAPSHOT-2018-12-07-a-ubunutu18.04.tar.gz -C /usr/local/bin
  5. Add Swift to your command line path:
    $ export PATH=/usr/local/bin/swift-DEVELOPMENT-SNAPSHOT-2018-12-07-a-ubuntu18.04/usr/bin:${PATH}
    Now, let’s run $ swift --version to make sure that we’ve downloaded and installed Swift correctly. You should see this output (or similar, depending on the version of the toolchain you installed):
    Swift version 5.0-dev (LLVM b10ce3d642, Clang c1979d7668, Swift 94b167db75)
    Target: x86_64-unknown-linux-gnu
  6. Clone and build Apple’s sourcekit-lsp project:
    $ git clone
    $ cd sourcekit-lsp
    $ swift build -Xcxx -I/usr/local/bin/swift-DEVELOPMENT-SNAPSHOT-2018-12-07-a-ubuntu18.04/usr/lib/swift
  7. Move sourcekit-lsp and to /usr/local/bin:
    $ sudo mv .build/x86_64-unknown-linux/debug/sourcekit-lsp /usr/local/bin
    $ sudo mv .build/x86_64-unknown-linux/debug/ /usr/local/bin
  8. Install Node.js 11.x or newer:
    $ curl -sL | sudo -E bash -
    $ sudo apt-get install -y nodejs
  9. Generate the extension for VS Code:
    $ cd Editors/vscode
    $ npm run createDevPackage
  10. Install the extension you just created:
    $ code --install-extension out/sourcekit-lsp-vscode-dev.vsix
  11. Point sourcekit-lsp at your installed toolchain in VS Code’s settings (File > Preferences > Settings > settings.json):
    sourcekit-lsp.toolchainPath: /usr/local/bin/swift-DEVELOPMENT-SNAPSHOT-2018-12-07-a-ubuntu18.04/usr/bin
  12. Reload your VS Code window (Control+Shift+P > Reload Window) or restart VS Code.

At this point, you’re all set up to use the Swift Language Server on linux. A few notes: you will see the most functionality for projects that have a Package.swift file that have been pre-built with swift build.

Let’s clone and build a sample project so we can see it in action:

$ git clone
$ cd Splash
$ swift build

Finally, open the Splash folder in VSCode and try some of the following to see it in action:

  • Hover over a struct name
  • Command+Click to jump to a definition
  • Type some code and invoke autocomplete

There has been a lot of enthusiasm around the announcement of this project, and for good reason. It serves as yet another reinforcement of Apple’s broad goals for the Swift programming language, which seem to extend further beyond the friendly confines of their own platforms with each passing year.

  1. Tested on Ubuntu 16.04 and 18.04. The commands below all specify the 18.04 versions where necessary.↩︎