A Build Server Protocol (BSP) implementation for Xcode projects, enabling better IDE integration with Swift and Objective-C codebases.
- 🔧 BSP 2.0 Support: Full compatibility with Build Server Protocol 2.0
- 🏗️ Xcode Integration: Seamless integration with Xcode build system
- ⚡ Fast Indexing: Efficient source code indexing and navigation
- 📁 Multi-target Support: Support for complex Xcode project structures
- 🔍 SourceKit Integration: Native Swift language server capabilities with complete
textDocument/sourceKitOptionsimplementation - 🛡️ Thread-safe: Robust concurrent operations with Swift actors
- 📊 Comprehensive Build Settings: Full support for per-file compiler arguments via
XcodeProj
See sourcekit-bsp in action with seamless code navigation and jump-to-definition:
- Download the latest release from GitHub Releases
- Extract and move to your PATH:
tar -xzf sourcekit-bsp-macos-universal.tar.gz sudo mv release/sourcekit-bsp /usr/local/bin/ chmod +x /usr/local/bin/sourcekit-bsp
git clone https://github.com/wang.lun/sourcekit-bsp.git
cd sourcekit-bsp
swift build -c release
cp .build/release/sourcekit-bsp /usr/local/bin/sourcekit-bsp# Not yet available
brew install sourcekit-bspCreate a buildServer.json file in your project root:.bsp/sourcekit-bsp.json
{
"name": "sourcekit-bsp",
"version": "0.2",
"bspVersion": "2.2.0",
"languages": [
"objective-c",
"objective-cpp",
"swift"
],
"argv": [
"path/to/sourcekit-bsp"
]
}sourcekit-lsp looks for configuration in the following order:
.bsp/*.jsonfiles (BSP standard)*.jsonin.bsp/directory for your project/workspace
buildServer.jsonin project root (legacy support)
NOTE: vscode-swift requires the buildServer.json file to be located in the root of your non-SwiftPM project.
For complex projects, create a .sourcekit-bsp/project.json configuration file:
{
"workspace": "YourProject.xcworkspace",
"project": "YourProject.xcodeproj",
"scheme": "YourScheme",
"configuration": "Debug"
}| Option | Description | Required |
|---|---|---|
workspace |
Path to .xcworkspace file | Yes* |
project |
Path to .xcodeproj file | Yes* |
scheme |
Xcode scheme to use | Yes |
configuration |
Build configuration (Debug/Release) | No (defaults to Debug) |
*Either workspace or project is required.
The .sourcekit-bsp/project.json file is required for:
- Multiple workspaces
- Multiple projects without a workspace
- Custom build configurations
- Projects/workspaces with multiple schemes for multi iOS apps that sourcekit-bsp can not guess which one is main
-
Install sourcekit-bsp using one of the installation methods above
-
Configure your project following the configuration section
-
Validate your project:
XcodeProjectCLI /path/to/projectFolder
This will check your project settings and report any issues.
-
Start the server:
sourcekit-bsp
-
Connect from your IDE: Configure your IDE to connect to the BSP server (typically on stdio).
Install the VSCode-Swift extension. For Swift versions lower than 6.1, configure:
{
"swift.sourcekit-lsp.serverPath": "/path/to/sourcekit-lsp",
"swift.sourcekit-lsp.toolchainPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"
}- macOS 12.0+
- Xcode 14.0+
- Swift 6.1+
swift buildswift test┌─────────────────┐ JSON-RPC ┌──────────────────┐
│ IDE │ ◄─────────────► │ sourcekit-bsp │
└─────────────────┘ └──────────────────┘
│
▼
┌─────────────────┐
│ Xcode Build │
│ System │
└─────────────────┘
- BSPServerService: Core BSP protocol implementation
- JSONRPCConnection: JSON-RPC transport layer
- ProjectManagerProvider : Provides access to the ProjectManager
- ProjectManager: Manages Xcode project/workspace parsing and build settings extraction
- XcodeProjectManager: Handles Xcode-specific project operations
- XcodeBuild Integration: Interface with xcodebuild tool
- SwiftPMProjectManager: (TODO)Handles SwiftPM-specific project operations
| Method | Status | Description |
|---|---|---|
build/initialize |
✅ Complete | Server initialization with capabilities |
build/initialized |
✅ Complete | Post-initialization notification |
workspace/buildTargets |
✅ Complete | List all build targets |
buildTarget/sources |
✅ Complete | Get source files for targets |
textDocument/sourceKitOptions |
✅ Complete | Per-file compiler arguments from buildSettingsForIndex |
buildTarget/prepare |
[ ] | Background indexing preparation |
buildTarget/didChange |
[ ] | Build target change notifications, need a BSP client with full feature |
workspace/didChangeWatchedFiles |
[] | File system change handling |
- Server not starting: Check that your configuration file is valid JSON
- Build failures: Ensure your Xcode project builds successfully first
- Index not updating: Verify that the scheme and configuration are correct
Logs are written to /tmp/sourcekit-bsp.log
# See if project can be resolved
XcodeProjectCLI resolveProject --workspace-folder /path/to/projectFolder
# See if buildSettings of project can be resolved
XcodeProjectCLI buildSettings \
--workspace-folder /path/to/projectFolder \
--xcodeproj relative/path/of/workspace-folder/to/{project}.xcodeproj \
--target targetNameInXcodeProj
# See if a source file compile arguments can be generated
XcodeProjectCLI compileArguments \
--workspace-folder /path/to/projectFolder \
--xcodeproj relative/path/of/workspace-folder/to/{project}.xcodeproj \
--target targetNameInXcodeProj \
--source-file relative/path/of/workspace-folder/to/source-file
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Inspired by sourcekit-bazel-bsp and xcode-build-server
This project is licensed under the MIT License - see the LICENSE file for details.
- Apple for SourceKit and the Swift toolchain
- The Build Server Protocol community
- Contributors to the Swift ecosystem
