Skip to content

Commit c3db710

Browse files
authored
Merge pull request #1251 from kateinoigakukun/yt/add-wasm-editor-setup
Add editor configuration instructions for Swift WebAssembly development
2 parents 5a870ed + 6d958f5 commit c3db710

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

documentation/articles/wasm-getting-started.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Build of product 'Hello' complete! (1.31s)
100100
Hello from WASI!
101101
```
102102

103-
# Embedded Swift Support
103+
## Embedded Swift Support
104104

105105
[Embedded Swift](https://github.com/swiftlang/swift-evolution/blob/main/visions/embedded-swift.md) is an experimental [subset of the language](https://docs.swift.org/embedded/documentation/embedded/languagesubset)
106106
allowing the toolchain to produce Wasm binaries that are multiple orders of magnitude smaller. One of the Swift SDKs in the artifact bundle you've installed
@@ -117,3 +117,57 @@ or
117117
```
118118
swift run --swift-sdk {{ tag }}_wasm-embedded
119119
```
120+
121+
## Editor Configuration
122+
123+
This section shows you how to configure your development environment for Swift WebAssembly development using the Swift SDKs you installed in the previous section.
124+
125+
### Visual Studio Code
126+
127+
If you haven't set up VSCode for Swift development yet, see the [Configuring VS Code for Swift Development guide](/documentation/articles/getting-started-with-vscode-swift/).
128+
129+
**Configure VSCode for WebAssembly:**
130+
131+
1. Open your Swift package in VSCode.
132+
133+
2. Use the Command Palette (`Cmd + Shift + P` on macOS, `Ctrl + Shift + P` on other platforms) and select `Swift: Select Toolchain...`.
134+
135+
3. Choose your Swift toolchain from the list (should match the version installed with `swiftly`).
136+
137+
4. When prompted, save the toolchain setting in **Workspace Settings**. This will create or update the `swift.path` setting in `.vscode/settings.json`.
138+
139+
5. Create a `.sourcekit-lsp/config.json` file in your project root:
140+
141+
```json
142+
{
143+
"swiftPM": {
144+
"swiftSDK": "{{ tag }}_wasm"
145+
}
146+
}
147+
```
148+
149+
Replace `{{ tag }}_wasm` with the exact Swift SDK ID from your `swift sdk list` output. Use `{{ tag }}_wasm-embedded` if you're working with Embedded Swift.
150+
151+
6. Reload VSCode using the Command Palette: `Developer: Reload Window`.
152+
153+
### Other Editors
154+
155+
For other editors (Vim, Neovim, Emacs, etc.) with LSP support already configured for Swift:
156+
157+
1. Ensure your editor is using the correct Swift toolchain (the one installed with `swiftly`).
158+
159+
2. Create a `.sourcekit-lsp/config.json` file in your project root:
160+
161+
```json
162+
{
163+
"swiftPM": {
164+
"swiftSDK": "{{ tag }}_wasm"
165+
}
166+
}
167+
```
168+
169+
Replace `{{ tag }}_wasm` with your Swift SDK ID from `swift sdk list`. Use `{{ tag }}_wasm-embedded` for Embedded Swift.
170+
171+
For initial Swift LSP setup guides, see:
172+
- [Zero to Swift with Neovim](/documentation/articles/zero-to-swift-nvim/)
173+
- [Zero to Swift with Emacs](/documentation/articles/zero-to-swift-emacs/)

0 commit comments

Comments
 (0)