我在这里看到了几个(好吧,不是很多,而是几个)关于 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/