【问题标题】:Is it possible to run the Swift REPL within an SSH session?是否可以在 SSH 会话中运行 Swift REPL?
【发布时间】:2014-06-09 01:19:06
【问题描述】:

有没有人尝试在本地或远程 SSH 会话中运行 Swift REPL?

xcrun swift 在本地终端会话中运行良好,但对我来说失败了

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

在 SSH 会话中(通过 iPad 远程或直接在我的桌面 Mac 上通过 ssh 进入 localhost)。

【问题讨论】:

  • 什么是ssh命令?您是尝试直接运行 REPL 还是在 bash 等登录 shell 中运行?

标签: swift read-eval-print-loop


【解决方案1】:

问题是 OSX 试图以图形方式提示您输入密码,但它不能通过 SSH 做到这一点。为了解决这个问题,您需要在机器上启用开发者模式。您可能通过在 Xcode 中调试项目(在不知不觉中)做到了,这会提示您启用开发人员模式。

您也可以从命令行运行它(包括通过 SSH):

sudo /usr/sbin/DevToolsSecurity --enable

【讨论】:

  • 谢谢,Kevin,这很有见地。
【解决方案2】:

假设 swift 在你的 shell 路径中:

$ 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

远程:

$ ssh -t gozoner@10.0.1.6 swift
Password:
Welcome to Swift!  Type :help for assistance.
  1> 1
$R1: Int = 1
  2> 10
$R2: Int = 10
  3> 

【讨论】:

  • 谢谢! REPL 现在在 SSH 会话中对我来说工作正常(从终端到本地主机,以及从我的 iPad 使用 Prompt)。也许我只需要在安装 XCode 6 或切换环境以使用 XCode 6 后重新启动我的 Mac。
  • 非常感谢“赞成票”(意识到您改变了对“答案”的看法)
猜你喜欢
  • 2016-11-27
  • 1970-01-01
  • 1970-01-01
  • 2011-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-29
  • 1970-01-01
相关资源
最近更新 更多