swift-meet-up-template-rectangle002
July Swift Meet Recap | Developing in Swift outside Xcode
swift-meet-up-template-rectangle002

As the Swift language evolves, there’s a growing demand for developers to use their preferred editor for development. Below is a comparison and exploration of writing Swift in three popular editors: Apple's Xcode, Microsoft's Visual Studio Code (vscode), and Neovim.

What Makes a Code Editor "Good?"

Tons of things play into the developer experience (DX) when writing source code. How easy and efficient it is to edit text, the ease of testing, debugging, profiling, and source control integration to name a few. Plus, a thousand other bells and whistles that can take you from little more than tapping in code line-by-line on a TRS-80 to blasting out dozens of files in the blink of an eye.

For most modern languages, though, one feature tends to stand out when comparing editors: Language Server Protocol (LSP) support (or an equivalent proprietary form of "code sense"). In recent years, it's become expected code editors should support an LSP, everything from cool new-kid-on-the-block Zed to 90's nostalgia trip acme.

Swift’s LSP server implementation, called sourcekit, is maintained as part of the official swiftlang group and works with the three editors we'll explore below.

Comparing Xcode, vscode, and Neovim

Below, you'll find a simple pros/cons comparison of each of these editors. It is important to note the importance of personal preference, which you can only determine by trying these out yourself! I encourage you to try all three and pick the one that fits best with your workflow. It's also worth considering what type of application you're planning to develop in Swift. If you're writing an iPhone app, you probably want an iPhone emulator. If you're instead writing a command line tool or embedded code, you’ll want a command line close by. These features may not exist in all of the editors we're going to compare, so it's important, as with everything in software development, to use the right tool for the job.

Xcode

xcode

Pros:

  • Developed by Apple and purpose-built for Swift development
  • Built-in emulators for Apple platforms (which can also be used with other editors, but require extra setup)
  • Configured to work out of the box—just install and start writing Swift immediately

Cons:

  • Extremely heavy weight (resource usage, executable size, etc).
  • macOS only
  • Not open-source
  • Limited language support.
  • Dreaded "Delete Derived Data" (and other bizarre issues) are often frustrating or have painfully unintuitive solutions

Visual Studio Code

visual-studio

Pros:

  • Enormous plugin ecosystem and good customizability
  • Lighter weight
  • Cross-platform & includes plug-and-play support for devcontainers
  • Open source
  • Works with Swift with a single plugin

Cons:

  • Additional setup and plugins are required for full IDE-like features (more robust git support, as an example)
  • Can get bogged down with plugins very quickly

Neovim

neovim

Pros:

  • Enormous plugin ecosystem and as customizable as you can get
  • Extremely lightweight
  • Cross-platform & completely open-source
  • Can tell people you use vim

Cons:

  • Extreme learning curve (modal editor, keybindings, etc)
  • Requires many plugins to have what could be considered a "streamlined" swift experience

Final Thoughts

cartoon

https://xkcd.com/378/

The editor you use when writing code, no matter what anyone tells you, should be what works best for you (unless you still use Notepad… then you should be ashamed). As with anything in software development, there isn't a silver bullet solution. Anything you choose will be better at some things and weaker at others. As for the three tools explored in this blog post, the bottom line comes down to what you're looking for:

  • Do you need something that "just works" out of the box, regardless of bloat? Then Xcode is probably your best bet.
  • Do you want something that you can precisely tailor to your every whim, at the expense of a steep learning curve and the acceptance of figuring out problems with little to no support? Then give neovim a try!
  • Do you want something that lands solidly in between the previous two, a strong jack-of-all-trades? Then it sounds like you may want to look at vscode!

Additional Resources

Here are some extra resources and guides that can get you up and running with the editors shown:

1 / 1
Twitter%20X