Swift-bsp: A Build Server Protocol implementation that uses swift-build

I'd like to share swift-bsp: an implementation of the Build Server Protocol that uses swift-build under the hood. It allows the Swift extension for VSCode (and other editors with LSP support) to work directly with Xcode projects.

I've been developing iOS and macOS apps for years, but Xcode isn't always the best fit for every workflow. With modern editors like Cursor gaining popularity, the benefits of working in alternative IDEs keep growing. Hopefully with swift-bsp that future comes a little bit closer.

It's still a little rough around the edges, but so far it has worked with every Swift-based Xcode project I've tried. The repo can be found at GitHub - wvteijlingen/swift-bsp · GitHub

Feedback and contributions are very welcome!

9 Likes

Hey, are you aware of xcode-build-server? Got any comments about how swift-bsp differs from this?

For context, I’ve been building Apple apps in Zed for some time now, with xcode-build-server as part of the puzzle. Results have been really good. To help with it all I built xcede, which eases build/run/test from the command line for Xcode projects, and also helps with debugging. (It’s not Zed-specific.) Here’s a writeup if you’re interested: Build, run and debug iOS and Mac apps in Zed instead of Xcode . Which reminds me, I must post here about all this.

Just dropped swift-bsp into an existing project and it seems to be working after a quick test.

It looks like xcode-build-server is written in Python/JS, whereas this seems to be written in Swift.

That alone is a selling point for the community to be able to contribute more readily.

1 Like

Hey, are you aware of xcode-build-server? Got any comments about how swift-bsp differs from this?

I've briefly used xcode-build-server as well, but found the developer experience not entirely optimal. From what I've seen I think it relies on xcodebuild output, which seems brittle to me. It also requires some configuration in buildServer.json, such as the scheme te use.

In contrast, swift-bsp interfaces directly with the official Swift build system (same build system used by Xcode), and requires much less setup.

Also, as tonyarnold mentioned, swift-bsp is written as a Swift Package which makes it much easier to adopt in the Swift ecosystem.

To help with it all I built xcede

Looks interesting, great to see the community work on supporting alternative IDE's! Perhaps it would be useful to see if you can get this into Sweetpad, which it currently the most well-known VSCode extension for Xcode projects.

To be fair, the one-liner xcode-build-server config -scheme Banana generally does it for me. It seems that scheme is optional and you can switch targets; it’s been a while since I’ve used it with a multi-target project so details are hazy.

According to the readme it works by parsing build logs. This does sound potentially fragile, although I haven’t found it so. I’ve just been pleased to have something that works!

If swift-bsp is a more robust solution (which I think is what you’re saying) and is a better long-term proposition, then great. Thanks for making it – these tools obviously fill a vital gap for working outside Xcode.

I don’t have much interest in VSCode personally, but perhaps someone will pick it up (this has happened for Neovim).