命令行中调试swift简单语句

时间:2014-10-10 15:01:15   收藏:0   阅读:190

背景

在命令行直观的看到代码输出,像解释性语言那样直观。

环境

MAC OSX10.10(Yosemite)系统,需要先安装Xcode6-Beta7(当前最新版本)。

步骤

命令行直接执行xcrun swift,会提示如下错误:

$xcrun swift
xcrun: error: unable to find utility "swift", not a developer tool or in PATH

自己的环境xcode5与xcode6并存,系统默认的xcode5不支持swift,故报此错误。这就需要设定默认xcode的版本。需要执行如下命令:

$sudo xcode-select --switch /Applications/Xcode6-Beta.app/Contents/Developer

然后再执行就可以了。

$xcrun swift
Welcome to Swift! Type : help for assistance.
    1>println ("hello world")
hello world

命令行执行lldb –repl和swift有同样的效果,还没弄清楚它们之间的区别。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!