我已经在这里看到了几个(好的,不是那么多,但有几个)问题来处理这个错误,但是没有一个提议的解决方案适合我。这就是我得到的
$ 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)上。想法?
答案 0 :(得分:11)
要查看当前的Xcode路径:
xcode-select -p
我是一条古老的道路:
/Applications/Xcode.app/Contents/Developer
然后通过以下方式更新此路径:
sudo xcode-select -s /Library/Developer/CommandLineTools