swift REPL will not launch in Mojave terminal

When I type swift at the prompt in the terminal window, the response is: error: failed to launch REPL process: process exited with status -1 (Error 1). I am running macOS Mojave 10.14.6 and xCode 10.3. I cannot get swift to start in the terminal window. I followed the procedure on the swift.org site to bring in the toolchains variable with the command: export TOOLCHAINS=swift. This does nothing and the error remains. At the command prompt ($) when I type

$ swift --version

Apple Swift version 5.1 (swiftlang-1100.0.38.29 clang-1100.0.20.14)

Target: x86_64-apple-darwin18.7.0

Anyone know how to launch swift in teminal on a macbook pro?

Replies

The Swift repl from Xcode 10.3 should work out of the box on 10.14.6. I used this regularly (before installing the Xcode 11.0 GM seed) and I just checked that it still works:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G95
$ swift
Welcome to Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.4).
…

You wrote:

I followed the procedure on the swift.org site to bring in the toolchains variable with the command

I recommend that you undo whatever you did here. You shouldn’t need to play around with toolchains to get this working; it should just work out of the box.

Also, check that you have Xcode 10.3 selected as your default Xcode. You can do this using

xcode-select
. If you have Xcode 10.3 installed in the usual place (
/Applications/
), you should see this:
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"