The missing Swift version manager.
$ brew tap neonichu/formulae
$ brew install chswift
Amend configuration as advised by the installation procedure.
Running without any arguments will show installed Swift versions and the currently selected one:
$ chswift
* 1.1 (swift-600.0.57.4)
1.2 (swiftlang-602.0.47.4 clang-602.0.48)
Specify a version number to change the current Swift:
$ chswift 1.2
$ swift --version
Apple Swift version 1.2 (swiftlang-602.0.47.4 clang-602.0.48)
Target: x86_64-apple-darwin14.3.0
Fall back to the Swift defined by your xcode-select
configuration:
$ chswift system
You can also configure a local environment in .swift-version files, which contain only the the version you want to use. To use Swift 1.2, do the following in your directory:
$ echo 1.2 >.swift-version
You can verify it's working using the following.
$ swift --version
Apple Swift version 1.2 (swiftlang-602.0.47.4 clang-602.0.48)
Target: x86_64-apple-darwin14.3.0
In order to have multiple Swift versions listed when you run chswift, you will need to have multiple Xcode versions running. The simplest way is to use xcode-install. If you rely solely on the Mac App Store, updates will change your system's Swift version.
$ brew install shunit2
$ make test
This project is based on ideas and code of the amazing chruby. If you are also in the market for a Ruby chooser, you have found it.