Skip to content

Repository files navigation

sourcekit-xcode-bsp

A Build Server Protocol server that connects sourcekit-lsp to native Xcode projects (.xcodeproj / .xcworkspace). It uses swift-build, the same build engine as Xcode, so Swift code intelligence works in Cursor, VS Code, and other LSP editors.

The server reloads when project metadata changes, such as project.pbxproj or Package.resolved.

Important

For native Xcode projects only. For Bazel, use sourcekit-bazel-bsp.

Note

Early-stage. APIs and setup may change.

Requirements

  • macOS 15+
  • Xcode 26+, selected with xcode-select (or DEVELOPER_DIR). You still need Xcode installed for SDKs and toolchains.
  • Swift 6.2+ to build from source

Install

Homebrew:

brew tap slime-studio/tap
brew install sourcekit-xcode-bsp

From source:

git clone https://github.com/slime-studio/sourcekit-xcode-bsp.git
cd sourcekit-xcode-bsp
swift build -c release
cp .build/release/sourcekit-xcode-bsp .build/release/SWBBuildServiceBundle /usr/local/bin/

SWBBuildServiceBundle must stay next to the sourcekit-xcode-bsp binary.

Setup

From your Xcode project root:

sourcekit-xcode-bsp init

This writes buildServer.json in the current directory. It detects a .xcworkspace or .xcodeproj, defaults the platform to iphonesimulator, and sets argv to the binary you just ran.

Then in Cursor or VS Code:

  1. Install the Swift extension.
  2. Open the folder that contains buildServer.json.
  3. Run Swift: Restart LSP Server from the command palette (Cmd+Shift+P), or reload the window.

sourcekit-lsp reads buildServer.json and launches this server over stdio. Bare sourcekit-xcode-bsp and sourcekit-xcode-bsp serve both run the server.

Configuration

buildServer.json lives at the workspace root. Minimal example:

{
  "argv": ["/usr/local/bin/sourcekit-xcode-bsp"],
  "bspVersion": "2.1.0",
  "languages": ["swift"],
  "name": "sourcekit-xcode-bsp",
  "version": "0.1.0",
  "workspace": "MyApp.xcodeproj"
}
Field Required Description
workspace Yes Path to .xcodeproj or .xcworkspace, relative to this file or absolute
buildRoot No Build artifacts directory. Defaults to .build/derived-data
platform No Run destination, such as iphonesimulator, iphoneos, or macosx. init defaults to iphonesimulator. If omitted, swift-build chooses one
serviceBundlePath No Path to SWBBuildServiceBundle. Defaults to the copy next to the binary
synchronousBuildDescriptionSerialization No Write the build description before notifying SourceKit-LSP, so the first diagnostics are not empty. Defaults to true

Development

swift build
swift test
swiftlint lint

Optional hook: brew install pre-commit swiftlint && pre-commit install. Commits then lint staged Swift files.

Troubleshooting

In Cursor or VS Code, open Output and choose SourceKit Language Server. After you open a Swift file you should see the BSP start. Server logs go to stderr with a prefix like [sourcekit-xcode-bsp:bootstrap].

  • buildServer.json not found: put the file in the folder your editor opened as the workspace root.
  • Workspace not found: workspace must point at a real .xcodeproj or .xcworkspace.
  • Xcode not found: run xcode-select -p and confirm Xcode 26+ is selected. Override with DEVELOPER_DIR if needed.

Related projects

License

Apache License 2.0. See LICENSE.

About

Build Server Protocol server that connects sourcekit-lsp to native Xcode projects

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages