I want to run swift code in the terminal
・ I want to check the execution result of swift on playground

Error message I wrote swift code in

playground (print ()etc.), but no result is displayed.

When you enterswiftin the terminal and execute it, the following message is output.

error: failed to launch REPL process: process exited with status -1 (unable to attach)
Supplemental information (FW/tool version etc.)

Xcode Version 9.4.1 (9F2000)
Swift version 4.1.2
macOS High Sierra 10.13.6


I use iMac, but install the OS on the external SSD, not the built-in HDD, and use it as a startup disk.
Is it something related?

  • Answer # 1

    Since no solution was found, we reinstalled OS and Xcode.

  • Answer # 2

    I don't know about the terminal, but if it's in a state where'Running playground'It seems that there are things that can be solved by changing fromto themacOSplatform. (By the way, playground adaptsiOSby default)

    So selectmacOSwhen creating a playground, or change the existing playground tomacOSUtilities>file inspector> Follow the steps in;Playground Setting>Platform>macOS.

    If you want to tryUIKit, this method will replaceAPPKit, so you will need to find another method.