Experience of using VSCode as a Swift IDE

One of the SSWG’s goals this year is to improve the tooling for server-side Swift. This includes making sure that you have a great experience developing Swift libraries and applications no matter the IDE or platform you choose.

To see the current state out Swift development outside Xcode I spent the week before WWDC using VSCode exclusively. Given I work on server-side Swift full time this meant using VSCode all day, every day!

Here are my findings:

TL;DR - whilst there are definitely some rough patches things were surprisingly good and I was mostly as productive as in Xcode.

Setup

I followed the link in the SSWG guide for configuring everything and also set up the Swift Development Environment. Whilst I got there we could do with some better guides for setting up LLDB, SourceKit and the LSP and we should definitely try and configure as much for users as possible (they shouldn’t have to go around digging for the path to SourceKit for example). A plugin that sets everything up in one go (Swift, LLDB, code completion, testing etc) would be an awesome addition.

The Good Parts

In general things worked pretty well! Syntax highlighting works, code completion worked for both local functions and functions in dependencies andLLDB worked! Seriously for the majority of stuff it was really good. I had to do the occasional restart throughout the week to fix things like code completion, jump to definition and placeholders but overall it was a great experience.

Pro tip - setting your keyboard shortcuts to match Xcode will make the transition much easier! :sweat_smile:

The Bad Parts

The biggest missing feature for me was a decent test integration. There’s a Swift extension for integrating with VSCode’s Test Explorer. On Linux this simply doesn’t work as there’s currently no way to get a list of tests out of SwiftPM that it can see with test discovery (SR-14885. On macOS it displays all the tests and you can click to run a test class or individual test but it just span and did nothing. You can of course still run tests using swift test.

Other grievances I had in no particular order:

  • No command shortcut to update dependencies
  • Autocomplete for initialisers doesn’t work - I had to write MyType.init( to get code completion
  • No refactoring support
  • No way to view all functions in a file (CTRL-5 in Xcode)
  • Code completion doesn’t work in placeholders for first word
  • No way to click through to code of dependencies
  • Specifying targets, how to build them, building individual targets is very manual and relies on a config file with hardcoded paths. This should be greatly improved
  • The warning/error UX when first opening a project and clicking through to them is flaky
  • LLDB debugging on macOS jumps into assembly code when trying to go into a function in certain scenarios.This might be related to EventLoopFutures?

Next Steps

I want to reiterate that despite the long list of bad parts things were really good! Hopefully we can get some additions to SwiftPM added to make things like testing easier and finding targets. Better guides for setting up would be a good step in improving things and a plugin that configured everything automatically would be a major step.

66 Likes

Update - after a pointer from @Daniel_Mullenborn I was able to get the tests on Linux working! The reason is that the build command and test command use different flags so it was constantly rebuilding. We should be able to solve this with docs/an extension that wraps everything

Screenshot 2021-07-08 at 16.02.17

21 Likes

Wow amazing :star_struck: can’t wait to pull it all together :heart:

Terms of Service

Privacy Policy

Cookie Policy