|
117 | 117 | ``` |
118 | 118 | swift run --swift-sdk {{ tag }}_wasm-embedded |
119 | 119 | ``` |
| 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