我已经在这里看到了几个(嗯,不是那么多,而是几个(关于处理此错误的问题,但没有一个建议的解决方案对我有用。这就是我得到的
$ 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