Demystify the Swift toolchain

Demystify the Swift toolchain

Β·

3 min read

A toolchain is a set of tools that compiles source code into executables that can run on your target device and normally includes a compiler, a linker, and run-time libraries.

The Swift language is managed as a collection of projects, each with its own repositories. The current list of projects, according to swift.org, includes:

  • The Swift compiler command-line tool
  • The standard library bundled as part of the language
  • Core libraries that provide higher-level functionality
  • The LLDB debugger which includes the Swift REPL
  • The Swift package manager for distributing and building Swift source code
  • Xcode playground support to enable playgrounds in Xcode.

An Xcode toolchain (.xctoolchain) includes a copy of the compiler, lldb, and other related tools needed to provide a cohesive development experience for working in a specific version of Swift.

Xcode includes a release of Swift that is supported by Apple. But you can use alternative toolchains, e.g. to try out a version that is still in development.

The default location for the downloadable toolchain on macOS is /Library/Developer/Toolchains. You can make the latest installed toolchain available for use from the terminal with the following command:

$ export TOOLCHAINS=swift

I recommend this blog post from Shashikant Jagtap on how to switch Swift versions inside Xcode (or for the command-line).

Switch Swift Version

About the inner structure of the Swift toolchain and how it helped to develop an Online Swift Playground I recommend this blog post from Marcin Krzyzanowski.

If you just want to know which Swift version is used in which Xcode version then this community page helps you out: swiftversion.net

https://swiftversion.net/

Did you find this article valuable?

Support Swifty Tech by Marco Eidinger by becoming a sponsor. Any amount is appreciated!