Skip to content

Commit 420c867

Browse files
committed
Add documentation of how to configure SourceKit-LSP for embedded projects
1 parent 219b11d commit 420c867

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

Documentation/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ The following documentation documents are intended for users of SourceKit-LSP.
77
- [Editor Integration](Editor%20Integration.md)
88
- [Enable Experimental Background Indexing](Enable%20Experimental%20Background%20Indexing.md)
99
- [Environment Variables](Environment%20Variables.md)
10+
- [Using SourceKit-LSP with Embedded Projects](Using%20SourceKit-LSP%20with%20Embedded%20Projects.md)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Using SourceKit-LSP with Embedded Projects
2+
3+
If you need to pass additional options in the `swift build` invocation to build your project, SourceKit-LSP needs to know about these as well to fully understand your project. To tell SourceKit-LSP about these options, add a `.sourcekit-lsp/config.json` file to your project’s root folder and add the arguments you pass to `swift build` to that configuration file as described [here](Configuration%20File.md).
4+
5+
For example, if you use the following invocation to build your project
6+
7+
```sh
8+
swift build \
9+
--configuration release \
10+
--triple armv7em-apple-none-macho \
11+
-Xcc -D__APPLE__ -Xcc -D__MACH__ \
12+
-Xswiftc -Xfrontend -Xswiftc -disable-stack-protector
13+
```
14+
15+
Then the `.sourcekit-lsp/config.json` file should contain
16+
17+
```json
18+
{
19+
"swiftPM": {
20+
"configuration": "release",
21+
"triple": "armv7em-apple-none-macho",
22+
"cCompilerFlags": ["-D__APPLE__", "-D__MACH__"],
23+
"swiftCompilerFlags": ["-Xfrontend", "-disable-stack-protector"]
24+
}
25+
}
26+
```

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ https://www.swift.org/tools has a list of popular editors that support LSP and c
1111
1212
To learn more about SourceKit-LSP, refer to the [Documentation](Documentation).
1313

14+
> [!NOTE]
15+
> If you are using SourceKit-LSP with a SwiftPM project in which you need to pass additional arguments to the `swift build` invocation, as is commonly the case for embedded projects, you need to teach SourceKit-LSP about those arguments as described in [Using SourceKit-LSP with Embedded Projects](Documentation/Using%20SourceKit-LSP%20with%20Embedded%20Projects.md).
16+
1417
## Reporting Issues
1518

1619
If you should hit any issues while using SourceKit-LSP, we appreciate bug reports on [GitHub Issue](https://github.com/swiftlang/sourcekit-lsp/issues/new/choose).

0 commit comments

Comments
 (0)