xcode - REPL 中的 `Error creating target Swift AST context: (null)`

标签 xcode swift command-line-interface read-eval-print-loop

我在这里看到了几个(好吧,不是很多,而是几个)关于 SO 处理这个错误的问题,但是没有一个建议的解决方案对我有用。这是我得到的

$ swift
Welcome to Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81). Type :help for assistance.
warning: Swift error in module repl_swift: 
    Error creating module Swift AST context: couldn't get a ClangImporter
Debug info from this module will be unavailable in the debugger.

warning: Swift error in module dyld: 
    Error creating module Swift AST context: couldn't get a ClangImporter
Debug info from this module will be unavailable in the debugger.

warning: Swift error in module CoreFoundation: 
    Error creating module Swift AST context: couldn't get a ClangImporter
Debug info from this module will be unavailable in the debugger.

...

warning: Swift error in module ServiceManagement: 
    Error creating module Swift AST context: couldn't get a ClangImporter
Debug info from this module will be unavailable in the debugger.

warning: Swift error in module libxslt.1.dylib: 
    Error creating module Swift AST context: couldn't get a ClangImporter
Debug info from this module will be unavailable in the debugger.

error: Error creating target Swift AST context: (null)

这可能是在我发出一些我不记得的命令后发生的,也可能没有发生(我的 bash 历史记录也没有太大帮助)。奇怪的是,如果我卸载 Xcode,REPL 就会开始正常工作。但是,如果我重新安装 Xcode,错误又会出现。顺便说一句,我在 Xcode 7.2.1 (7C1002) 上。想法?

最佳答案

查看当前的 Xcode 路径:

xcode-select -p

我的是一条老路:

/Applications/Xcode.app/Contents/Developer

然后通过以下方式更新此路径:

sudo xcode-select -s/Library/Developer/CommandLineTools

关于xcode - REPL 中的 `Error creating target Swift AST context: (null)`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35438851/

相关文章:

ios - 错误 : SDK "iphonesimulator9.0" Cannot be located

ios - (空)libc++abi.dylib : terminate called throwing an exception

ios - 我正在创建一个 Collection View ,其中所有单元格的高度都是随机的。如何使单元格之间的垂直间距为0?

ios - 如何在通过 Facebook 身份验证访问的多个 iOS 设备上保存数据?

ios - Moya/Alamofire - 具有相同键的 URL 编码参数

angular - 如何在没有 cli 的情况下构建 angular 2 应用程序

java - Sonar-runner.bat 在构建调用提供编译类时显示错误

iphone - CGBitmapContextCreate 的内存使用率非常高

ios - 无法在自定义键盘扩展中设置主要语言

javascript - Semmle CodeQL CLI : "QL dataset is not compatible with the QL"