# Demystify the Swift toolchain

A  [toolchain](https://en.wikipedia.org/wiki/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](https://swift.org/about/#swiftorg-and-open-source), 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](https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/AlternativeToolchains.html), e.g. to try out a [version that is still in development](https://swift.org/download/#snapshots).

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:

```bash
$ export TOOLCHAINS=swift
```

I recommend [this blog post](http://shashikantjagtap.net/switching-swift-versions-inside-xcode-using-toolchains/) from Shashikant Jagtap on how to switch Swift versions inside Xcode (or for the command-line).

![Switch Swift Version](https://cdn.hashnode.com/res/hashnode/image/upload/v1615055684290/uFrJ0EltA.png)

About the inner structure of the Swift toolchain and how it helped to develop an  [Online Swift Playground](http://online.swiftplayground.run/) I recommend [this blog post](https://blog.krzyzanowskim.com/2018/10/11/dealing-with-a-swift-toolchain/) from [Marcin Krzyzanowski](https://twitter.com/krzyzanowskim).

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

![https://swiftversion.net/](https://cdn.hashnode.com/res/hashnode/image/upload/v1615055508326/Du5q3RVZL.png)









