The Swift programming language can be setup with VS Code with most IDE features Xcode has like code completion, static analysis, indexing and debugging on Linux.
Requirements:
swift-arm64 repository and for x86_64 download from Swift.org.code-server to remotely run VS Code in the browser.code-server then just download the extension and install the VSIX file..vscode folder to build and debug the target. This can vary based on the package’s executables and libraries. The following is an example for Foo package..vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
// compile your SPM project
{
"label": "swift-build",
"type": "shell",
"command": "swift build"
},
// compile your SPM tests
{
"label": "swift-build-tests",
"type": "process",
"command": "swift",
"group": "build",
"args": [
"build",
"--build-tests"
]
}
]
}
.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/.build/debug/FooTool",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "swift-build"
},
{
"type": "lldb",
"request": "launch",
"name": "Test",
"program": "./.build/debug/FooPackageTests.xctest",
"preLaunchTask": "swift-build-tests"
}
]
}
swift build) to update indexing and completion features. This also applies to warning about missing dependencies.Swift Error Breakpoint, create a breakpoint for the symbol swift_willThrow in VS Code.