# Building with nightly Swift toolchains on macOS

DevFeed: [Building with nightly Swift toolchains on macOS](<https://devfeed.tech/articles/building-with-nightly-swift-toolchains-on-macos-21725.md>)

Original publisher: [Read original article](<https://oleb.net/2024/swift-toolchains/>)

Author: Ole Begemann

Published: 2024-03-05T18:54:44Z

Content type: tutorial

Language: en

Sources: [Ole Begemann](<https://devfeed.tech/sources/ole-begemann.md>)

Topics: [Swift](<https://devfeed.tech/topics/swift.md>), [toolchains](<https://devfeed.tech/topics/toolchains.md>), [macOS](<https://devfeed.tech/topics/macos.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Xcode](<https://devfeed.tech/topics/xcode.md>), [Package manager](<https://devfeed.tech/topics/package-manager.md>)

Tags: [command-line](<https://devfeed.tech/tags/command-line.md>), [macos](<https://devfeed.tech/tags/macos.md>), [swift](<https://devfeed.tech/tags/swift.md>), [swift-package-manager](<https://devfeed.tech/tags/swift-package-manager.md>), [toolchains](<https://devfeed.tech/tags/toolchains.md>), [xcode](<https://devfeed.tech/tags/xcode.md>)

## AI overview

A practical guide to installing and selecting nightly Swift compiler toolchains on macOS. It covers using custom toolchains in Xcode and from the command line, including the TOOLCHAINS environment variable and bundle IDs. The article also notes limitations such as unsupported playgrounds, built-in Swift Package Manager behavior, and App Store submission restrictions.

## Source excerpt

The Swift website provides nightly builds of the Swift compiler (called toolchains) for download. Building with a nightly compiler can be useful if you want to check if a bug has already been fixed on main, or if you want to experiment with upcoming language features such as Embedded Swift, as I've been doing lately. A toolchain is distributed as a .pkg installer that installs itself into /Library/Developer/Toolchains (or the equivalent path in your home directory). After installation, you have several options to select the toolchain you want to build with: In Xcode In Xcode, select the toolchain from the main menu (Xcode > Toolchains), then build and/or run your code normally. Not all Xcode features work with a custom toolchain. For example, playgrounds don't work, and Xcode will always use its built-in copy of the Swift Package Manager, so you won't be able to use unreleased SwiftPM features in this way. Also, Apple won't accept apps built with a non-standard toolchain for submission to the App Store. On the command line When building on the command line there are multiple options, depending on your preferences and what tool you want to use. The TOOLCHAINS environment variable All of the various Swift build tools respect the TOOLCHAINS environment variable. This should be set to the desired toolchain's bundle ID, which you can find in the Info.plist file in the toolchain's directory. Example (I'm using a nightly toolchain from 2024-03-03 here): # My normal Swift version is 5.10 $ swift --version swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) # Make sure xcode-select points to Xcode, not to /Library/Developer/CommandLineTools # The Command Line Tools will ignore the TOOLCHAINS variable. $ xcode-select --print-path /Applications/Xcode.app/Contents/Developer # The nightly toolchain is 6.0-dev $ export TOOLCHAINS=org.swift.59202403031a $ swift --version Apple Swift version 6.0-dev (LLVM 0c7823cab15dec9, Swift 0cc0590933