Skip to content

Instantly share code, notes, and snippets.

@radxene
Created January 11, 2022 10:36
Show Gist options
  • Save radxene/8abf3bd1cc88b96247b857fe24cfc2b4 to your computer and use it in GitHub Desktop.
Save radxene/8abf3bd1cc88b96247b857fe24cfc2b4 to your computer and use it in GitHub Desktop.
Swift Development with Visual Studio Code

Swift Development with Visual Studio Code

Visual Studio Code (VSCode) is a cross-platform text and source code editor from Microsoft. It’s one of the most exciting open source projects today, with regular updates from hundreds of contributors.

Step 0: Install Xcode

If you don’t already have Xcode installed on your machine, open the Terminal app and run the following command:

xcode-select --install

You can verify that everything is working as expected by running the sourcekit-lsp command:

xcrun sourcekit-lsp

Exit the process with an ETX signal (^C).

Step 1: Install Visual Studio Code

Download Visual Studio Code and install it to your system Applications folder. Open the app and follow the instructions for launching from the command line. You’ll need to have the code command accessible from $PATH in order to install the SourceKit-LSP extension later on.

Step 2: Install Node and NPM

brew install node
node --version
npm --version

Step 3: Build and Install SourceKit-LSP Extension for VsCode

From the command line, clone the sourcekit-lsp repository and use npm to build the extension and then use the code command to install it:

git clone https://github.com/apple/sourcekit-lsp.git
cd sourcekit-lsp/Editors/vscode
npm install
npm run dev-package
code --install-extension sourcekit-lsp-development.vsix

If you get an error stating Couldn't start client SourceKit Language Server, you may also need to specify the sourcekit-lsp executable path, which you can find using xcrun:

xcrun --find sourcekit-lsp
# for example output:
/Library/Developer/CommandLineTools/usr/bin/sourcekit-lsp

Copy the printed value and enter it into the setting for Server Path under Preferences > Settings, Extensions > SourceKit-LSP, and then Reload Window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment