问题描述
在这里,我已经看到了几个有关解决此错误的问题(不是很多,而是几个),但是没有一个建议的解决方案对我有用。这就是我得到的
I've seen several (well, not that many, but a few) questions here on SO dealing with this error, but none of the proposed solutions worked for me. This is what I get
$ 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)。有想法吗?
This may or may not have happened after I issued some command that I don't remember (and my bash history does not help very much). The odd thing is that if I uninstall Xcode, the REPL starts working correctly. If I re-install Xcode, however, the errors come back. I'm on Xcode 7.2.1 (7C1002), by the way. Thoughts?
推荐答案
查看当前的Xcode路径:
To see your current Xcode path:
xcode-select -p
矿山是一条古老的道路:
Mine was an old path:
/Applications/Xcode.app/Contents/Developer
然后通过以下方式更新此路径:
Then update this path via:
sudo xcode-select -s / Library / Developer / CommandLineTools
这篇关于在REPL中创建目标Swift AST上下文时出错:(空)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!