|
1 | 1 | # Enable Experimental Background Indexing |
2 | 2 |
|
3 | | -Background indexing in SourceKit-LSP is available as an experimental feature. This guide shows how to set up background indexing and which caveats to expect. |
| 3 | +> [!IMPORTANT] |
| 4 | +> Background indexing is enabled by default in Swift 6.1 toolchains and above. This guide only refers to Swift 6.0 toolchains. |
| 5 | +
|
| 6 | +Background indexing in SourceKit-LSP is enabled by default in Swift 6.1 toolchains and is available as an experimental feature for Swift 6.0 toolchains. |
4 | 7 |
|
5 | 8 | ## Behavior Without Background Indexing |
6 | 9 |
|
7 | | -By default SourceKit-LSP does not update its global index in the background or build Swift modules in the background. Thus, a lot of cross-module or global functionality is limited if the project hasn't been built recently. For example consider two modules: `Lib` and `Exec`, where `Exec` depends on `Lib`: Without background indexing, if a function is added to `Lib`, completion/jump to definition/etc in `Exec` would not be able to see that function until after a build. Background indexing solves that issue. |
| 10 | +With background indexing disabled SourceKit-LSP does not update its global index in the background or build Swift modules in the background. Thus, a lot of cross-module or global functionality is limited if the project hasn't been built recently. For example consider two modules: `Lib` and `Exec`, where `Exec` depends on `Lib`: Without background indexing, if a function is added to `Lib`, completion/jump to definition/etc in `Exec` would not be able to see that function until after a build. Background indexing solves that issue. |
8 | 11 |
|
9 | 12 | ## Set Up |
10 | 13 |
|
11 | | -1. Install a `main` or `release/6.0` Swift Development Snapshot from https://www.swift.org/install or install the [Xcode 16 beta](https://developer.apple.com/xcode/). |
12 | | -2. Point your editor to the newly installed toolchain. |
13 | | - - In VS Code on macOS this can be done by adding the following to your `settings.json`: |
14 | | - - For open source toolchains `"swift.path": "/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin"` |
15 | | - - When installing the Xcode 16 beta `"swift.path": "/Applications/Xcode-beta.app/Library/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"` |
16 | | - - In VS Code on other platforms, you need to set the `swift.path` to the `usr/bin` directory of your toolchain’s install location. |
17 | | - - Other editors likely also have a way to pick the Swift toolchain, the exact steps vary by your setup. |
| 14 | +1. Install the Swift 6.0 toolchain or install [Xcode 16](https://developer.apple.com/xcode/). |
18 | 15 | 3. Enable the experimental `background-indexing` feature by creating a [configuration file](Configuration%20File.md) with the following contents at `~/.sourcekit-lsp/config.json` with the following contents: |
19 | 16 | ```json |
20 | 17 | { |
21 | | - "backgroundIndexing": true |
| 18 | + "backgroundIndexing": true, |
| 19 | + "backgroundPreparationMode": "enabled" |
22 | 20 | } |
23 | 21 | ``` |
24 | 22 |
|
|
0 commit comments