You can write and build Swift code in VS Code. Make sure to download the official Swift extension inside of VS Code.
How to build
To build Swift code in Visual Studio Code, you need to set up a task that will run the Swift compiler. Here’s how you can do it:
- Open the Command Palette with
Cmd+Shift+P
. - Type “Tasks: Configure Default Build Task” and select it.
- Select “Create tasks.json file from template”, and then “Others”.
- Replace the content of the generated
tasks.json
file with the following:
This task will run the swift build
command whenever you run the Build Task (Cmd+Shift+B
).