我读过What's new in Xcode 6。本文介绍了Xcode6的一些新特性,并表示:
命令行
Xcode的调试器包括Swift语言的交互式版本,称为REPL (Read-Eval-Print-Loop)。使用Swift语法评估正在运行的应用程序并与之交互,或者在类似脚本的环境中编写新代码。REPL可以从Xcode控制台中的LLDB中获得,或者从终端中获得。
我想知道如何获得REPL?
发布于 2014-06-03 17:34:02
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
然后,您可以执行以下操作之一:
xcrun swift
lldb --repl
从Xcode6.1开始,在终端中输入swift
也会启动REPL。
发布于 2014-06-03 23:54:38
或者,如果你不想弄乱你当前的开发环境,你可以直接运行:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
发布于 2014-07-13 05:41:55
步骤1:打开终端
第二步:输入"swift“
第三步:没有第三步
示例:
GoldCoast:~ macmark$ swift
Welcome to Swift! Type :help for assistance.
1> println("Hello, world")
Hello, world
2> var myVariable = 42
myVariable: Int = 42
3> myVariable = 50
4> let myConstant = 42
myConstant: Int = 42
5> println(myVariable)
50
6> let label = "The width is "
label: String = "The width is "
7> let width = 94
width: Int = 94
8> let widthLabel = label + String(width)
widthLabel: String = "The width is 94"
9> :exit
GoldCoast:~ macmark$
https://stackoverflow.com/questions/24011120
复制相似问题