Category Archives: Xcode

Having Xcode Code Completion Problems?

After installing Xcode 8, I had some problems with code completion as well as getting to the documentation when holding down the Apple key when clicking a keyword.

Deleting derived data

When serching for the problem on the interwebz, the go to recommendation was deleting derived data, and restarting Xcode. So I did, and to my frustration it did not help. Neither did rebooting my Mac.

Solution TL;DR

I suddenly discovered that only UIKit was imported, while Foundation was not imported once in any of my source files. This should not have any impact, because the source would build and run without any problem, but Xcode SourceKit did stop working when I did not have any reference directly to it. The moment I added import Foundation to a UIViewController, and Apple + clicked a keyword, it worked just great.

Bug or Not?

First of all, the frameworks I did import in my source files does depend on Foundation, so I can’t find any good reason for why this would happen. Also in a couple of other completely different projects, documentation as well as code completion did reappear after I imported Foundation in that first project. So I guess its a SourceKit related bug that suddenly disables documentation and code completion. The solution was for the project somehow re-index the code, and then kind of resetting SourceKit.
And just to make it clear, I deleted derived data, restarted Xcode, cleaned up and jumped through all hoops before the import Foundation trick did the trick 😉

So yes, I guess its a bug, and I have filed a radar (rdar://28479377). Hopefully Apple will mark it as duplicate, and have it fixed in the next release.