Xcode 9 "an internal error occurred. source editor functionality is limited. attempting to restore"

Today when I tried to create a new project I quickly noticed that I got an error:

"an internal error occurred. source editor functionality is limited. attempting to restore"


Which is weird, a project that was created literally 5 seconds ago shouldn't have any errors, right?

So I closed it and opened an older project, no errors there.

Next I deleted the new project and recreated it. Still the same error.


I cleaned derived data, restarted Xcode, restarted my mac, even went as far as completely uninstalling Xcode and then reinstalling it, but I still get the same error.


Not only does that error stop me from using auto-completion and other nice editor features, but also from creating outlets for my views


Hopefully someone here has an idea how to fix this.

Accepted Reply

your reply got me thinking, so far I always named the project the same, so I tried naming it different.

I'm currently following the "Hacking with Swift" series and I'm naming the projects after the chapters/things that I learn in them.

In this case it was "CoreGraphics"


So I deleted the project, created a new one simply name "TestProject". Sure enough it worked.

Then I deleted that one, created a project named "CoreGraphics" again and with the name the same error appeared again.

I tried this a few more times just to be sure and everytime the name of the project was "CoreGraphics" the error would appear, but not with different names

Names such as "TestCoreGraphics" or "LearningAboutCoreGraphics" work just fine.


Not sure why it is just CoreGraphics because I previously named projects after other chapters (e.g. "GrandCentralDispatch" and "UserDefaults")


I guess it's probably bad practice to name my projects in such a way, but my thought process here was to have a "Learning" folder and have the projects as self-explanatory as possible so I could quickly revisit a topic if I wanted to

Replies

You would normally get this messsage only when your write some source code that (in effect) crashes the compiler.


To be specific, the error occurs in a separate process called SourceKit, which is a partial Swift compiler — just enough to analyze the syntax of your source code. Something is very wrong if SourceKit crashes on a brand new project. If this is repeatable with a brand-new project, then you should submit a bug report (including the project), via the link at the bottom right of this page.


What version of Xcode and what version of macOS are you using?

I already submitted a bug report, thought without the project since it happens on every project that I create. Only old projects are not affected.


I'm using macOS 10.13.3 and Xcode 9.2 (9C40b) which should be the newest available versions afaik

The reason for submitting the newly-created project is that the problematic source is presumably in there somewhere, but others might not be able to create exactly that. For example, some stuff (like the comments at the top of source files) is created with a template, using information from user defaults (and even your "me" record in Contacts). If there's something odd in there, it might not be visible in the editor, but still a problem for SourceKit.

your reply got me thinking, so far I always named the project the same, so I tried naming it different.

I'm currently following the "Hacking with Swift" series and I'm naming the projects after the chapters/things that I learn in them.

In this case it was "CoreGraphics"


So I deleted the project, created a new one simply name "TestProject". Sure enough it worked.

Then I deleted that one, created a project named "CoreGraphics" again and with the name the same error appeared again.

I tried this a few more times just to be sure and everytime the name of the project was "CoreGraphics" the error would appear, but not with different names

Names such as "TestCoreGraphics" or "LearningAboutCoreGraphics" work just fine.


Not sure why it is just CoreGraphics because I previously named projects after other chapters (e.g. "GrandCentralDispatch" and "UserDefaults")


I guess it's probably bad practice to name my projects in such a way, but my thought process here was to have a "Learning" folder and have the projects as self-explanatory as possible so I could quickly revisit a topic if I wanted to

>>Not sure why it is just CoreGraphics because I previously named projects after other chapters (e.g. "GrandCentralDispatch" and "UserDefaults")


Ah, there is a reason. By default, your project name is used as the module name of your main app module. Unfortunately, there is an existing module called "CoreGraphics", which is normally imported into any iOS or macOS project compilation. Clearly, that drives SourceKit crazy, leading to a crash.


You should definitely upgrade your bug report with this information, since it's arguably an actual bug that SourceKit can get this confused this easily.

Yea, I already got a reply mail to the inital bug report asking me to update with additional info, which I did

In my case, it was just a silly "!" mark :( let params = [         "_id": data.id       ] as! [String:String]

I removed "!" beside "as" because xCode was showing a warning.!

Then I ran into this issue.. I wasted almost 2 hours deleting & installing xCode and derived data files.. Although the error was show-cased in Issues Pane.. I run through each error and finally got to this one.. When I added "!", the weird error was gone.!

Hope this Helps.!

Thanks.