A Build Server Protocol (BSP) server for Xcode projects and SwiftPM packages. For Xcode projects, it supplies compiler arguments to SourceKit-LSP and runs build, run, test, and debug operations. For SwiftPM packages, it loads targets, dependencies, and source lists on macOS and Linux. It builds root package targets, runs executable products, runs root test targets, and supports executable and test debugging on macOS.
- Discover projects, workspaces, sources, and target dependencies.
- Supply compiler arguments and optionally prepare dependencies for SourceKit-LSP indexing.
- Build and test targets; launch applications and debug on macOS or a simulator.
- Refresh project state after client file notifications and cancel active builds.
- Report build/test/index stages, compiler diagnostics, and readable output through standard BSP notifications.
The server implements a subset of BSP 2.2.0. See protocol support for capabilities and limitations. These docs describe the current source tree; older releases may have fewer features.
Download the latest sourcekit-bsp-macos-universal.tar.gz from the
GitHub Releases page.
mkdir -p ~/.local/lib/sourcekit-bsp ~/.local/bin
tar -xzf sourcekit-bsp-macos-universal.tar.gz -C ~/.local/lib/sourcekit-bsp
ln -sf ~/.local/lib/sourcekit-bsp/sourcekit-bsp ~/.local/bin/sourcekit-bsp
sourcekit-bsp --helpOr build and install the executables directly from this Swift package with Mint:
mint install aelam/sourcekit-bspKeep the server, SWBBuildServiceBundle, and resource bundles together.
Mint installs these components automatically. For a manual installation, add
~/.local/bin to your PATH.
On macOS, building requires Swift 6.2+, macOS 15+, Xcode, and your project's SDKs
and simulator runtimes. Linux builds require Swift 6.1+. On Linux, install the Swift toolchain
and run swift build without DEVELOPER_DIR.
git clone https://github.com/aelam/sourcekit-bsp.git
cd sourcekit-bsp
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
swift buildThe executable is .build/debug/sourcekit-bsp; swift build -c release produces
.build/release/sourcekit-bsp. See Getting started
for Xcode builds and executable paths.
Xcode project diagnostics are available as subcommands:
sourcekit-bsp xcode-project --help
sourcekit-bsp xcode-project resolve-project --workspace-folder /path/to/project-folderUse the folder that contains the .xcodeproj or .xcworkspace.
Use the Release workflow in GitHub Actions to prepare a release. Run it from
main and choose patch, minor, or major. The workflow commits the update to
SourceKitBSPVersion.current directly to main. For example, from 0.2.8,
the choices produce 0.2.9, 0.3.0, and 1.0.0.
The same run builds the selected commit, creates the matching v*.*.* tag, and
uploads the release assets. It does not create a version PR.
Manual release preparation uses the dedicated Deploy Key in RELEASE_SSH_KEY.
The key can bypass the PR and CI requirements for the version commit. Ordinary
changes still require a PR and the required checks. Force pushes and deletion of
main remain blocked for every actor, including the release key. GitHub applies
the PR and CI exception to all Deploy Keys in the repository.
The version comes from the commit selected when the run starts. Retrying that
run reuses its version commit, even if main later advances. If main advances
before preparation, start a new run from main. Existing tags are reused only
when they point to the same release commit. The version commit still triggers
normal CI, but its push skips duplicate publication through a Release-Run marker.
Tag pushes are still supported. The tag must match SourceKitBSPVersion.current;
otherwise the release workflow stops before it builds or uploads artifacts.
version="$(
sed -n 's/^[[:space:]]*static let current = "\(.*\)"[[:space:]]*$/\1/p' \
Sources/sourcekit-bsp/SourceKitBSPVersion.swift
)"
git tag -a "v$version" -m "Release v$version"
git push origin "v$version"vscode-bsp is a general BSP client for VS Code that provides build, run, test, and debug controls. The Swift extension runs SourceKit-LSP for code completion and navigation. Each client uses its own BSP connection.
Xcode builds from separate sourcekit-bsp processes coordinate access to the same
DerivedData directory with a file lock. After upgrading, restart both clients'
servers once older builds finish. Xcode GUI builds and manual xcodebuild commands
do not participate in this lock. See indexing and paths.
-
Install the server as described above and follow the vscode-bsp installation steps. For Swift editing, also install the Swift extension.
-
Create
.bsp/sourcekit-bsp.jsonin your application's root folder, alongside its.xcodeprojor.xcworkspace:{ "name": "sourcekit-bsp", "version": "1.0", "bspVersion": "2.2.0", "languages": ["swift", "c", "cpp", "objective-c", "objective-cpp"], "argv": ["/absolute/path/to/sourcekit-bsp"] } -
Replace the
argvpath with the absolute path to your installed or built executable. -
Open that application folder in VS Code, or add it as a folder in a workspace. Its
.bspdirectory must be at that folder's root. -
vscode-bsp discovers and connects to the server on activation. If needed, run BSP: Connect BSP Servers from the Command Palette.
-
Run BSP: Show Build Targets to open BSP. Expand the server's Build Context to select the scheme, configuration, and destination. Use its Compile Target, Build and Run, Build and Test, or Build and Debug Target action, as supported.
Use the same Xcode toolchain for the server and Swift extension.
After rebuilding the selected executable, restart both clients' server connections.
The clients start the executable in argv; running it directly waits for protocol messages on stdin.
For projects with multiple workspaces, configure .sourcekit-bsp/project.json;
see project configuration.
The optional --enable-build-target-prepare flag uses Swift Build to prepare dependency
modules and generated files without a full application build. SourceKit-LSP then
indexes source files in the background. Compile, Run, Test, and Debug continue to
use the existing Xcode execution paths.
The server starts Swift Build when it receives the first indexing request. It plans the requested target and its dependencies instead of planning every target during the BSP connection handshake.
macOS builds and Mint installations include Swift Build support by default. The launch flag controls whether the server uses it. Build from this repository with the selected Xcode toolchain:
swift build --product sourcekit-bspPoint .bsp/*.json at .build/debug/sourcekit-bsp. Keep the matching
SWBBuildServiceBundle executable and resource bundles beside the server;
copying only sourcekit-bsp is insufficient.
Add the flag to the server's argv in .bsp/*.json. Any BSP client that starts
this command uses the same setting:
{
"argv": [
"/absolute/path/to/sourcekit-bsp",
"--enable-build-target-prepare"
]
}The flag is off by default. When present, it enables dependency preparation when
SourceKit-LSP sends buildTarget/prepare. It does not start background indexing
or build the full application. Remove the flag to restore no-op preparation.
Project and workspace selection can use .sourcekit-bsp/project.json.
Enable SourceKit-LSP background indexing separately in .vscode/settings.json:
{
"swift.sourcekit-lsp.backgroundIndexing": "on"
}The Hello demo enables preparation in .bsp/config.json and LSP
background indexing in .vscode/settings.json. After rebuilding the server or
changing these settings, run Developer: Reload Window in VS Code.
The backend uses the project's existing DerivedData directory:
| Data | Path within DerivedData |
|---|---|
| Application build products | Build/Products |
| Index preparation products | Index.noindex/Build/Products |
| Index preparation intermediates | Index.noindex/Build/Intermediates.noindex |
| Compiler index data | Index.noindex/DataStore |
| SourceKit-LSP index database | IndexDatabase.noIndex |
Preparation omits some compilation work, so its modules do not replace normal application build products. Sharing the index store does not guarantee that SourceKit-LSP can reuse every index record from an Xcode build.
The indexing roots, platform, and configuration follow the resolved build context when Build, Run, Test, or Debug starts. Targets and dependencies in that scope share one Swift Build description. Requests outside that graph use supplemental descriptions. Changing a menu selection alone does not update the indexing context. This uses existing BSP requests and file notifications. See Swift Build indexing for validation commands.
A parent workspace can keep several connection files in .bsp. Each file starts
an independent server process with its own targets and execution context. All
connections initialize with the same parent workspace URI.
The server accepts one of --package PATH, --project PATH, or --workspace PATH.
Relative paths are resolved against build/initialize.rootUri, not the process's
working directory. A launch selection takes precedence over the parent's
.sourcekit-bsp/project.json and remains selected across reloads. The three
selectors are mutually exclusive; malformed options fail on stderr before the
stdio server starts. These are sourcekit-bsp CLI options carried in the standard
argv field, not new BSP fields or requests.
For example, place these four files in the parent .bsp directory:
.bsp/swift-a.json:
{"name":"Swift A","argv":["sourcekit-bsp","--package","packages/A"],"version":"1.0","bspVersion":"2.2.0","languages":["swift"]}.bsp/swift-b.json:
{"name":"Swift B","argv":["sourcekit-bsp","--package","packages/B"],"version":"1.0","bspVersion":"2.2.0","languages":["swift"]}.bsp/xcode-a.json:
{"name":"Xcode A","argv":["sourcekit-bsp","--project","apps/A/App.xcodeproj"],"version":"1.0","bspVersion":"2.2.0","languages":["swift"]}.bsp/xcode-b.json:
{"name":"Xcode B","argv":["sourcekit-bsp","--project","apps/B/App.xcodeproj"],"version":"1.0","bspVersion":"2.2.0","languages":["swift"]}Use --workspace apps/A/App.xcworkspace for an Xcode workspace instead of a
project. Xcode connections require macOS. SwiftPM products stay in each package's
build directory; Xcode derived data is keyed by the selected container path, so
projects with the same product name have separate outputs. Context IDs belong to
one connection and cannot be used on another connection.
SourceKit-LSP 6.4 cannot select a specific connection when a workspace contains multiple Swift/C-family connection files. Target-level BSP operations can use these independent connections, but individual test discovery and source locations need a matching SourceKit-LSP connection. The companion vscode-bsp client reports this ambiguity. Use separate workspace folders with one Swift connection each when individual test discovery is required.
The BSP workspace can contain a package at its root or in a subdirectory.
Keep the connection file in the workspace's .bsp directory and send that
workspace's URI in build/initialize. A nested package does not need its own
connection file.
To select a package explicitly, create .sourcekit-bsp/project.json at the
workspace root:
{"package": "p3"}The path is relative to the workspace root; an absolute path or a path to
Package.swift is also accepted. package cannot be combined with project or
workspace. An explicit package selects the SwiftPM provider even if an Xcode
project is present. Invalid selections fail without an automatic fallback.
Reconnect after changing the selected package.
Without an explicit selection, SwiftPM first checks the workspace root. If there
is no root manifest, it searches for one nested package. Discovery stops below
each package and skips hidden directories, symlinks, and common build or dependency
cache directories such as .build, node_modules, Pods, and DerivedData.
Multiple packages require an explicit selection; the error lists their paths.
Generated .swiftpm/xcode/package.xcworkspace metadata does not select the Xcode
provider, including symlink aliases. Selecting that metadata with --workspace
fails with a --package hint. If a real Xcode container and a root Package.swift
coexist, automatic discovery requires an explicit build-system selection.
This discovery and configuration behavior is a sourcekit-bsp feature, not a
requirement of the BSP standard. Build commands, outputs, and default run/test
working directories use the selected package root; context workspace scopes use
the original workspace root.
The SwiftPM provider loads package metadata with swift package describe --type json. It
exposes targets, source files, dependencies, and workspace reloads without building
package products. It loads local packages and uses swift package show-dependencies
to locate resolved remote dependencies. Resolution can download packages. Plugins,
macros, and binary targets are omitted from the build target list with warnings. Dependency edges are not yet
filtered by platform or build configuration.
The Swift executable must be on PATH. If SWIFT_EXEC selects a swiftc
compiler, the provider uses the swift executable in the same directory.
Root package targets support buildTarget/compile. Executable targets with one
product support buildTarget/run and, on macOS, debugSession/start through the
active Xcode toolchain's LLDB adapter. Root test targets also support debugging.
Library and dependency targets do not
advertise run or debug support. Dependency targets are built through their root
package dependents.
Compile builds the selected target or executable product. For a test target, it
uses swift build --build-tests to link the test runner; this can build other test
targets in the package. Without the context extension, run and debug use the
existing product without building it. Compile first, with the same SwiftPM build
arguments, such as --configuration release or --scratch-path /path/to/build.
The target controls product selection; package-path and target-selection overrides
are rejected. Run supports the server's environment and working-directory fields. Process output is streamed, and cancellation stops active commands.
With the context extension, run and debug prepare products using the resolved configuration. Run arguments are application arguments on this path; the context supplies the build settings.
Root test targets support buildTarget/test. The server uses swift test and a
module filter to run only the selected targets, including XCTest and Swift Testing.
SwiftPM can build other test targets as part of this command. Test arguments accept
build configuration options, --skip-build, parallel execution, and code coverage.
Clients can select individual functions with the optional
sourcekit-test-selection payload. Parameterized functions run all their arguments.
The server rejects extra test filters and commands that do not run tests. Tests
run from the package root and support environment variables. SwiftPM can buffer
output; the server forwards it as it arrives. After each target completes, the
server reports case results from XCTest output and Swift Testing events. Missing
selected results and test failures return an error. Cancellation stops the runner.
See test discovery and selection.
The server locates SourceKit-LSP through the selected Swift executable's runtime
metadata, so a toolchain shim does not become the language-server path. When the
toolchain includes SourceKit-LSP, root test targets advertise discovery metadata
for source navigation and editor test actions. Without it, target testing remains
available.
Test debugging lists the existing test bundle's tests without running them.
Without the context extension, compile the test target first with the same build
arguments. Context execution prepares the bundle first. The debugger launches Xcode's xctest runner with
the selected module's test identifiers. XCTest and Swift Testing run in the same
process, so source breakpoints work for both frameworks. The server supports
SwiftPM's separate test bundles and native build system's combined test bundle.
Test targets do not support ordinary Run. Test identifiers that contain commas
cannot be passed to the XCTest selector and return an error. debugSession/start
returns a DAP address. The client sends DAP launch; the server supplies the test
runner, arguments, environment, and working directory to the native adapter.
Use an updated vscode-bsp client.
Build output paths come from swift build --show-bin-path; this query does not
compile the package. After a successful build or test in the current connection,
the server uses its configuration and scratch directory for the affected targets.
Before a build, or after reconnecting, it uses SwiftPM's default build options.
This provider does not yet supply compiler arguments or prepare indexes. It advertises these capabilities as unsupported. SourceKit-LSP's native SwiftPM integration remains the option for SwiftPM code navigation.
On macOS, an Xcode project takes precedence when the folder also contains
Package.swift. Native Windows server support is not verified.
Both providers advertise dependencyModulesProvider and handle
buildTarget/dependencyModules. The response contains one item per requested
target, including an empty module list for targets without external libraries.
Unknown targets return an invalid-parameters error. The query uses the loaded
project snapshot and does not run a build or resolve packages.
SwiftPM reports external package products, including binary products, and follows transitive dependencies in the loaded target graph. Xcode reports package products and linked external frameworks and libraries for each target and its workspace target dependencies. Xcode does not enumerate dependencies inside package products; SDK libraries and products of workspace targets are excluded.
Package versions come from Package.resolved formats 1, 2, and 3. A revision is
used when no version is available, followed by a branch name. Local packages,
unresolved packages, and linked binaries have an empty version. Version constraints
are not reported as resolved versions. Workspace reloads refresh the module list.
The optional data field uses these server-specific kinds:
swiftpm: packageidentity,repository, and source-rooturi, when available.xcode: librarypath,sourceTree, and resolved fileuri, when available.
With Python 3, run from this repository root:
bsp_project="$PWD/Tests-MacOS/XcodeProjectManagementTests/Resources/DemoProjects/HelloProject"
python3 Scripts/bsp_client.py --project "$bsp_project"
python3 Scripts/bsp_client.py --project "$bsp_project" \
--method buildTarget/compile --target HelloThe probe uses .build/debug/sourcekit-bsp by default. Use --server to select
another build. The probe does not read Hello's .bsp/config.json. Pass
--enable-build-target-prepare to test dependency preparation with a server
built with Swift Build support.
See the client guide for options.
The optional vscode-bsp.build-context extension, version 0.1, discovers and
resolves execution settings for Xcode and SwiftPM. It is an experimental extension,
not part of the BSP standard. Other clients can keep using the standard requests.
Compiler-information requests such as buildTarget/scalacOptions,
buildTarget/javacOptions, and SourceKit compiler options describe the current
compiler inputs. This extension instead lists selectable execution settings.
Selecting these settings does not change the language server's indexing context.
With --enable-build-target-prepare enabled, starting an operation synchronizes the resolved
scheme roots, destination, and configuration with the indexing backend.
Add this object to build/initialize parameters under data.bspExtensions:
{
"vscode-bsp.build-context": { "version": "0.1" }
}The server accepts the extension by returning the following entry under
result.data.bspExtensions. It preserves dataKind: "sourceKit" and the existing
SourceKit initialization fields. The supported operation list can vary by provider.
Targets retain toolchain and test discovery metadata. Configuration and destination
choices are queried through workspace/contextOptions; targets no longer carry
the private data.selectors lists. Clients that used those lists must adopt
the context extension to offer execution settings.
{
"vscode-bsp.build-context": {
"version": "0.1",
"required": true,
"operations": ["compile", "run", "test", "debug"],
"buildPolicies": ["build", "reuse"]
}
}Only an exact version match enables this mode. After acceptance, all compile,
run, test, and debug requests on that connection must include a resolved
executionContext. Missing or invalid context references fail; the server does
not fall back to default settings. Clients that do not negotiate the extension
keep the existing request behavior.
| Method | Purpose |
|---|---|
workspace/contextOptions |
Return available configuration dimensions and effective selections. |
workspace/resolveContext |
Validate a selection and return a context ID and its target set. |
The discovery parameters contain only scope and selection. operation is
part of resolution, not configuration discovery.
Start discovery without an operation or target:
{
"scope": { "workspaceUri": "file:///workspace/Demo" },
"selection": {}
}For Xcode, the response supplies all three dimensions: Scheme, Configuration,
and Destination. Scheme contains the full list. The other fields remain visible
with enabled: false and a reason until a Scheme is chosen. Send its ID in the
next query to fill their options and enable them:
{
"selection": { "xcode.scheme": "scheme-id-returned-by-the-server" }
}Discovery does not require the user to choose Build, Run, Test, or Debug first.
Only after an action is chosen does resolution require its operation:
{
"operation": "run",
"selection": {
"xcode.scheme": "scheme-id-returned-by-the-server",
"xcode.configuration": "Release",
"xcode.destination": "destination-id-returned-by-the-server"
}
}scope, workspaceUri, targets, and selection are optional. An explicit
workspace must match the initialized workspace. Omit targets to discover a
workspace execution entry, such as an Xcode scheme. An explicit target list
restricts the execution scope; an empty list is invalid. A resolve operation is one of
compile, run, test, or debug.
The options result contains dimensions, selection, and optional operations
for the selected scope. Each dimension has
id, label, kind, required, options, and an optional current value.
Optional enabled and reason fields describe whether the user can edit the
dimension. Omitted enabled means enabled. Clients display disabled dimensions
and their reasons, but do not open an option picker for them.
Version 0.1 supports kind: "enum". Each option has an opaque id, a display
label, and optional description, reason, and boolean availability fields.
An explicit availability: false marks an unavailable option. Do not infer
capabilities or build-tool arguments from an ID. Unknown required dimension kinds
must prevent execution in the client.
Options can also include dataKind and data for structured display metadata.
The custom execution-destination data kind describes a destination:
{
"id": "destination-id-returned-by-the-server",
"label": "iPhone 16",
"availability": true,
"dataKind": "execution-destination",
"data": {
"kind": "simulator",
"platform": { "id": "ios", "label": "iOS" },
"osVersion": "18.5",
"identifier": { "label": "UDID", "value": "F76DD514-D57D-475E-9C1A-EB230A2FF86B" }
}
}The kind field is an open string. The platform object contains id and
label. Known kinds include host, device, simulator,
emulator, remote, container, and generic. Optional osVersion,
architecture, and state fields describe known properties. Providers omit
unknown values. Clients use these fields for display only; they must not infer
execution capabilities from a destination kind or state. Unknown data kinds or
destination kinds fall back to the option's label and description.
| Metadata field | Meaning |
|---|---|
kind |
Destination type; unknown kinds remain valid. |
platform |
Platform ID and display label. |
osVersion |
Optional known OS version. |
architecture |
Optional known architecture. |
state |
Optional observed state, such as connected or booted. |
identifier |
Optional display identifier with label and value, such as an actual device or simulator UDID. |
The display identifier is separate from the option's opaque id, which remains
the selection key. Clients must not parse an option ID to invent a display
identifier. Xcode supplies identifier only for devices and simulators with an
actual UDID. Generic destinations and host entries with synthetic platform IDs
omit it. SwiftPM host destinations also omit it.
Xcode supplies platform, destination type, and known OS versions from its device
inventory. Its current simulator inventory does not report boot state, so that
field is omitted. SwiftPM reports its host platform and architecture from the
selected toolchain's target information; a deployment version is not a host OS
version. availability and execution validation remain independent of metadata.
Dimensions are ordered from earlier choices to dependent choices. When the user
changes a dimension, the client queries options in that order and keeps later
explicit choices that remain enabled and available. It removes only choices that
are no longer valid, including removed or disabled dimensions. Selecting the
current value does not clear later choices. Server defaults returned by discovery
do not become saved user preferences. Version 0.1 uses this ordered model;
servers must supply a suitable order.
Within one server connection, a dimension ID has the same meaning and value namespace across workspace and target scopes. Use different IDs when the meaning is different. Clients can inherit explicit workspace choices for dimensions with matching IDs in a target scope; workspace-only choices do not enter that target selection. The server validates the resulting selection against the exact target scope during resolution. Incompatible choices fail instead of selecting a different scheme, configuration, or destination silently.
Xcode workspace discovery always orders its fields as Scheme, Configuration, and Destination. The provider enables dependent fields after their prerequisites are satisfied. An automatic value can satisfy a prerequisite; display order does not require the user to click every field. A target scope limits the applicable scheme actions. Common discovery does not invent a single default configuration for all actions. Omitted configuration and destination choices are resolved when an action is requested. Run and test defaults come from their scheme actions. SwiftPM supplies configuration and the supported host destination, with a target selection when needed. It does not supply a scheme. Unknown selection keys fail. Xcode discovery can retain an invalid choice as unavailable with a reason so the user can change it. Resolution rejects incompatible selections. Discovery and resolution do not build targets, generate schemes, or change a global selection. Workspace discovery reads the selected scheme and uses loaded metadata for the other scheme options. Target lookups use the canonical project path and target identifier. Project reloads rebuild this lookup; selected scheme edits are read on the next query. Target-scoped discovery still checks scheme membership.
Xcode destinations come from the local device inventory and platform build
settings. These checks do not replace xcodebuild -showdestinations validation
for a scheme. Generic destinations can be used for builds; run, test, and debug
require a concrete destination. Refresh options after changing a scheme or
configuration, and before using a saved selection. Xcode option discovery returns
an existing inventory snapshot immediately. Once that snapshot is two seconds
old, discovery starts a shared background refresh; the displayed list can remain
briefly out of date while that refresh runs. Queries without a valid scheme do
not scan devices. A background refresh failure invalidates the reusable snapshot,
so the next discovery query waits for a new scan and reports any failure. Context
resolution and execution always wait for a fresh scan or an in-flight refresh;
a refresh failure prevents execution instead of using an older snapshot.
Xcode target operations only use existing schemes. If no matching scheme exists, the operation reports an error that asks the user to create or share a scheme in Xcode. The server does not generate scheme files in the project.
Context operation buttons reflect the selected scheme's Build, Run, and Test actions and their target membership. Build-action checkboxes describe which targets participate in each build; they do not make a library runnable or create a test action. Configuration, destination, and backend execution constraints are checked when an operation is resolved, without hiding the scheme's actions.
Xcode test contexts use the scheme's default Test Plan when one is configured.
The server reads its enabled test targets to validate the requested scope and
passes the plan name to xcodebuild. Xcode applies the plan's test settings,
configurations, and test filters. Selecting a different Test Plan is not exposed
as a context option yet. Ambiguous scheme or plan names are rejected.
Application Run and Debug read enabled arguments and environment variables from the selected scheme and expand build-setting references. The server passes these values to the application launcher. The scheme's custom LLDB initialization file is not applied or used to determine which operations are available. Debugger initialization remains controlled by the existing debugger configuration. Unsupported launch settings, such as action scripts and custom working directories, still prevent context execution.
Test debugging supports one app-hosted unit test target on an iOS simulator. It does not yet support Test Plans or custom test action settings. Unavailable options include a reason. These limits apply to the context path.
The resolve response contains id, operation, targets, buildPolicy, and the effective
selection. IDs belong to the current connection. They can be reused while valid;
they are not task IDs or persistent settings. The server keeps at most 128 resolved
contexts. Reconnection, project reload, cache eviction, or a changed selection can
require resolution again. Execute requests revalidate the stored selection.
Use the existing BSP methods. For example, after resolving a test context:
{
"jsonrpc": "2.0",
"id": 12,
"method": "buildTarget/test",
"params": {
"targets": [{ "uri": "target-uri-returned-by-the-server" }],
"originId": "test-12",
"executionContext": { "id": "context-id-returned-by-resolve" }
}
}The additional executionContext field is also an extension. The request's
operation and target set must match the resolved context; buildTarget/run still
uses its standard single target field. Results, diagnostics, task events, test
reports, cancellation, and DAP connections keep their existing formats.
Execution settings stay separate from application arguments, test selection data, environment variables, and the working directory. Conflicting build flags fail instead of overriding the selected configuration. By default, context execution builds the required products with that same configuration.
workspace/resolveContext also accepts an optional buildPolicy: "build"
(the default) or "reuse". For example, Run Without Building resolves a run
context with "buildPolicy": "reuse". The response echoes the policy, and the
context ID freezes it along with the scheme, configuration, destination, and
targets. The execute request still sends only executionContext: {"id": "..."}.
A client can offer Without Building only when the negotiated buildPolicies
contains "reuse". If the field is absent, only "build" is supported. When
present, the list must contain "build" and can also contain "reuse". The client
must check that resolution returned the requested policy; an omitted response
policy means "build" for compatibility. Compile rejects "reuse". Unsupported
policies and policy mismatches fail instead of falling back to a build. Test
arguments cannot override the frozen policy; "build" rejects --skip-build.
With "reuse", run and debug require existing products. Test uses
xcodebuild test-without-building or swift test --skip-build, retaining the
selected tests and execution settings. Missing products fail without a fallback
build. Product lookup, build-setting queries, installation, and launch can still
run; they do not compile products. Both application and test debugging follow
this policy. Revalidation preserves and checks the frozen policy.
This version does not provide a configuration-change notification or a general
UI schema. Query options when configuring an operation and resolve before starting
it. Invalid extension parameters and context references return JSON-RPC
InvalidParams (-32602). Do not parse error text or automatically retry with
default settings.
- Getting started
- Build, run, test, and debug
- Indexing and build paths
- Swift Build index preparation
- Protocol support and lifecycle payloads
- Troubleshooting
- Wiki sources
CI=true MACOS_CI=true swift test --enable-code-coverageCI=true skips tests that use personal project paths. Xcode integration tests use bundled
fixtures and require Xcode SDKs. SwiftPM loading tests use temporary local packages
on macOS and Linux without Xcode or remote package dependencies.
See Contributing.
Inspired by sourcekit-bazel-bsp and xcode-build-server. Licensed under the MIT License.
