Skip to content

Commit

Permalink
Add VSCode guide
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Sep 10, 2024
1 parent 5eae9b2 commit 3e73346
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [JavaScript interoperation](getting-started/javascript-interop.md)
- [Concurrency](getting-started/concurrency.md)
- [Testing your app](getting-started/testing.md)
- [Visual Studio Code](./getting-started/vscode.md)
- [Debugging](getting-started/debugging.md)
- [Troubleshooting](getting-started/troubleshooting.md)
- [Examples](examples/index.md)
Expand Down
2 changes: 1 addition & 1 deletion src/getting-started/setup-snapshot.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installation - Development Snapshot

## WebAssembly SDK - Cross compile to WebAssembly
## Swift SDK for WebAssembly - Cross compile to WebAssembly

The upstream Open Source Swift toolchain does support WebAssembly as a target platform since **Swift 6.0**.
For those versions, you just need to install [Swift SDK for cross-compilation](https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md).
Expand Down
Binary file added src/getting-started/vscode-editing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions src/getting-started/vscode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Configuring Visual Studio Code with WebAssembly SDK

This guide will help you configure Visual Studio Code (VSCode) to use the Swift SDK for WebAssembly.

> **Note**: This guide assumes you have already installed the [Swift SDK for WebAssembly](./setup-snapshot.md) from the development snapshot release.
## Prerequisites

- [Visual Studio Code](https://code.visualstudio.com/)
- [Swift for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang)
- [Swift Development Snapshot](https://swift.org/install) (`swift-DEVELOPMENT-SNAPSHOT-2024-09-04-a` or later)
- [Swift SDK for WebAssembly](./setup-snapshot.md)


## Configure your SwiftPM package

1. Open your Swift package in VSCode.
2. Create a `.vscode/settings.json` with the following content:

```json
{
"swift.path": "<path-to-swift-toolchain-from-swift.org>/usr/bin",
}
```

> **Note**: Replace `<path-to-swift-toolchain-from-swift.org>` with the path to the development snapshot Swift toolchain you downloaded from [swift.org/install](https://www.swift.org/install).
3. Create a `.sourcekit-lsp/config.json` with the following content:

```json
{
"swiftPM": {
"swiftSDK": "<Swift SDK id>"
}
}
```

> **Note**: Replace `<Swift SDK id>` with the Swift SDK id you installed using the `swift sdk install` command. You can find the installed SDK id by running `swift sdk list`.
4. Reload the VSCode window by pressing `Cmd + Shift + P` and selecting `Reload Window`.

That's it! You can now build and auto-complete your Swift package using the Swift SDK for WebAssembly.

![](./vscode-editing.png)

0 comments on commit 3e73346

Please sign in to comment.