Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`Error creating target Swift AST context: (null)` in REPL

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)

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?

like image 661
Morpheu5 Avatar asked Feb 16 '16 17:02

Morpheu5


1 Answers

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

like image 144
aguilarpgc Avatar answered Nov 18 '22 07:11

aguilarpgc