如何在终端中使用 swift? [英] How can I use swift in Terminal?

查看:74
本文介绍了如何在终端中使用 swift?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了 Xcode 6 的新功能.这篇文章介绍了一些关于 Xcode 6 的新特性,它说:

I read What's new in Xcode 6. The article introduces some new feature about Xcode 6, and it says:

命令行

Xcode 的调试器包括一个交互式版本的 Swift 语言,称为 REPL(Read-Eval-Print-Loop).使用 Swift 语法评估正在运行的应用程序并与之交互,或者在类似脚本的环境中编写新代码.REPL 可从 Xcode 控制台的 LLDB 内或从终端获得.

Xcode’s debugger includes an interactive version of the Swift language, known as the REPL (Read-Eval-Print-Loop). Use Swift syntax to evaluate and interact with your running app or write new code in a script-like environment. The REPL is available from within LLDB in Xcode’s console, or from Terminal.

我想知道如何获得 REPL?

I want to know how to get the REPL?

推荐答案

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

然后您可以执行以下操作之一:

then you can do one of these:

xcrun swift 
lldb --repl

从 Xcode 6.1 开始 - 在终端中输入 swift 也会启动 REPL.

As of Xcode 6.1 - typing swift in the terminal launches the REPL as well.

这篇关于如何在终端中使用 swift?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆