Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run the Swift REPL within an SSH session?

Has anyone tried running the Swift REPL within a local or remote SSH session?

xcrun swift runs great within a local Terminal session, but fails for me with

error: failed to launch REPL process: process exited with status -1) (lost connection)

in an SSH session (either remotely via iPad or when ssh'd into localhost directly on my desktop Mac).

like image 740
James Collins Avatar asked Jun 09 '14 01:06

James Collins


2 Answers

The problem is that OSX is trying to prompt you graphically for your password, but it can't do that over SSH. To get around this, you need to enable developer mode on the machine. You probably did it (unknowingly) by debugging a project in Xcode, which prompts you to enable developer mode.

Developer mode prompt

You can also run this from the command line (including over SSH):

sudo /usr/sbin/DevToolsSecurity --enable
like image 91
Kevin Avatar answered Oct 11 '22 08:10

Kevin


Assuming swift is in your shell path:

$ ssh -t localhost swift
Password:
Welcome to Swift!  Type :help for assistance.
  1> 1
$R1: Int = 1
  2> var foo = 10
foo: Int = 10
  3> foo + 1
$R2: Int = 11

and remotely:

$ ssh -t [email protected] swift
Password:
Welcome to Swift!  Type :help for assistance.
  1> 1
$R1: Int = 1
  2> 10
$R2: Int = 10
  3> 
like image 1
GoZoner Avatar answered Oct 11 '22 09:10

GoZoner