Issue with VS-Code and Swift Toolchain Selection

I am attempting to use the latest development toolchain snapshot with VS Code for swift embedded (swift-6.1-DEVELOPMENT-SNAPSHOT-2025-01-23-a.xctoolchain), however, I am encountering the following error when trying to build an embedded Swift example:

<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs).
  • VS Code appears to default to the system Swift toolchain, with the following configuration:
Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Program arguments: /Library/Developer/CommandLineTools/usr/bin/swift-frontend -frontend -target riscv32-none-none-eabi -disable-objc-interop -I [...]
  • I set the custom toolchain path in the settings.json file of VS Code as follows:
"swift.path": "/Library/Developer/Toolchains/swift-6.1-DEVELOPMENT-SNAPSHOT-2025-01-23-a.xctoolchain/usr/bin"

However, VS Code still defaults to the system toolchain.

  • Attempts to set the toolchain path directly via CMake failed because the toolchain argument is either omitted or overwritten. In Xcode, I successfully set the default toolchain to swift-6.1-DEVELOPMENT-SNAPSHOT-2025-01-23-a.xctoolchain, but this does not seem to influence VS Code.
  • Using export TOOLCHAINS=org.swift.610202501231a in the terminal works only for that specific shell session. Processes spawned from VS Code do not inherit this environment variable.

What I’ve Tried:

  1. Setting the swift.path in VS Code's settings.json file.
  2. Configuring CMake to use the custom toolchain (toolchain arguments seem overwritten or omitted).
  3. Setting the default toolchain in Xcode.
  4. Exporting the TOOLCHAINS environment variable (org.swift.610202501231a) manually in a shell session, which works in that shell but not for VS Code processes.

Request for Help:

How can I force VS Code and/or CMake to use the provided custom Swift toolchain (swift-6.1-DEVELOPMENT-SNAPSHOT-2025-01-23-a.xctoolchain) instead of defaulting to the system one? Alternatively, how can I manage the toolchain switch system-wide so that all processes, including those spawned by VS Code, consistently use the custom toolchain?

Hi! I had a somewhat similar problem. Adding
export TOOLCHAINS='org.swift.610202412211a'
to
~/.zshrc
solved it for me.
Have you tried adding this export there ?

1 Like

Thanks a lot. That workaround fixed it.