My Hackathon Camp Project: Building a Swift IDE

Hackathons are the longest running tradition in Facebook’s engineering culture. This hackathon featured a “summer camp” theme and spanned three days. I decided to use that time to build an IDE for Swift.

Three days isn’t enough time to build an IDE application from scratch. Instead, I built a relatively small package that integrated into Nuclide, which itself is a package for the Atom editor. I call the package nuclide-swift.

Atom and Nuclide are “hackable”: they expose APIs (called “services”) that allow plugins (called “packages”) to interact with every single part of the editor. In fact, nearly every feature of Atom – its file tree sidebar, its open file buffer, its panes – is implemented as a package.

Scroll down for some demos of what I was able to accomplish in three days of Nuclide development. Scroll further for things to come, and for details on when and how you’ll be able to use these features.

 What nuclide-swift can do today

 Build Swift packages via a toolbar

Click "Build" on the Swift toolbar to build a Swift package

I used the service to display a toolbar to build Swift packages. The toolbar provides a GUI that interacts the Swift package manager command line interface, swift build. Build output is displayed via the nuclide-output service.

 Test Swift packages via that same toolbar

Click "Test" on the Swift toolbar to run a Swift package's tests

Another integration between the service and the Swift package manager’s swift test command. I highlight the test failures in this demo, but don’t expect to see this UI in the official release – it’ll use the nuclide-test-runner service instead.


Autocompletion suggestions come from SourceKit, and are as accurate as anything you'd see in Xcode

nuclide-swift registers itself as an autocomplete.provider service. It uses the build commands generated by the Swift package manager, and feeds those to SourceKitten. SourceKitten is a convenient wrapper for Apple’s SourceKit, the technology behind the autocompletion suggestions Xcode provides.

I’m proud of this integration. Most Swift editor plugins I’ve seen don’t provide SourceKitten with build commands, and as a result their autocompletion suggestions are inaccurate or incomplete. nuclide-swift, thanks to its build integration, can get autocompletion suggestions on par with Xcode.

 Type hints

Hover over a Swift symbol to see its type

nuclide-swift also registers as a nuclide-type-hint.provider, to display type information for any Swift symbol you hover over. Another happy collaboration between Nuclide, the Swift package manager, and SourceKitten.

 Outline view

A visual hierarchy of the Swift symbols defined in the current source file

sourcekitten structure meets nuclide-outline-view to displays the hierarchy of symbols – classes, structs, methods, variables – defined in a Swift source file. Clicking on a symbol in the outline view moves your cursor to that position in the source code.

This feature comes thanks to Nat Mote, a member of the Nuclide team. Nat also answered a bunch of my Nuclide and JavaScript questions. Thanks, Nat!

 Automatically format Swift source code

Hit ⌘⇧C to format the Swift code in the current file

sourcekitten format and nuclide-code-format.provider join forces to end the “tabs vs. spaces” debate once and for all.

This feature comes thanks to Nico Reed.

 Swift package commands

Invoke other Swift package manager commands via the Nuclide command palette

Create a new Swift package, fetch its dependencies, and more, all from within Nuclide.

This feature comes thanks to Kevin Casey.

 Coming soon to nuclide-swift

 Display errors in your Swift code as you type

Errors appear as red underlines as you type. Hover over the side pane for error details

This won’t be hard to do, thanks to SourceKit and the nuclide-diagnostics-provider service. I’ll be sending pull requests to SourceKitten to add the commands I need.

 ⌘-click to jump to declaration

⌘-click to jump to where a Swift symbol was declared

The hyperclick.provider service makes it easy to jump to another source code location via ⌘-click, and I think SourceKit can provide the declaration location.

 Remote development

Establish a remote connection to work on a server-side Swift app

One of Nuclide’s killer features is its ability to connect to remote servers when editing. It’s trivial to modify nuclide-swift so that it can connect to a server. This would allow you to edit the source code for your server-side Swift application, build it, run its tests, attach a debugger – all from the Nuclide IDE.

 Better testing support

List tests in a package, via a "Test Navigator" sidebar

It should be possible to lists tests in a package, display pass/fail in the gutter, and re-run tests by clicking on them, thanks to a combination of swift test --list-tests, SourceKit’s is_test_candidate flag, and Nuclide’s gutter APIs. I’m still learning about all the features of the nuclide-test-runner service, so expect the UI here to change a lot.

 How do I install this?

You can install Nuclide right now, but the features here won’t be available to download for a week or two. I coded most of these features during a hackathon, and now I need to clean the code up and add some unit tests.

If you’d like to contribute, send your pull requests to my nuclide-swift branch.


A lot of open-source software made these features possible, but it’s hard to express just how awesome SourceKitten is. Kudos to JP Simard, Norio Nomura, and all the other contributors. ❤️


Now read this

XCTest: The Good Parts

Since my last post about testing, I’ve been involved with a discussion on Twitter with Apple’s Joar Wingfors: @modocache I’d love to talk about that too! @jspahrsummers @rob_rix— Joar Wingfors (@joar_at_work) February 28, 2015 I was... Continue →

Subscribe to ⌘U

Don’t worry; we hate spam with a passion.
You can unsubscribe with one click.