Xcode 8.2 Code Completion Not Working

Xcodexcode8.2

Xcode Problem Overview


For some reason, in Xcode 8.2 my code completion has stopped working. I have cleaned my product, restarted Xcode, restarted my computer, and deleted the derived data, and still no luck. I have submitted this to Apple Support. Has anyone run into this before and been able to fix it?

Xcode Solutions


Solution 1 - Xcode

Update: As per @Dareon solution below also works for Xcode Version 8.3 (8E162) and 8.3.2 (8E2002). Thanks, @Dareon for the confirmation. :)

I was facing the same issue and following worked for me.

I am using Xcode Version 8.2.1 (8C1002).

  1. Go to Xcode > Preferences > Text Editing
  2. Under Code completion - Uncheck 'Suggest completions while typing'
  3. Quit out of Xcode and then relaunch Xcode.
  4. Go to Xcode > Preferences > Text Editing again
  5. Quit out of Xcode and then relaunch Xcode.
  6. Now go to Code completion and check 'Suggest completions while typing'.
  7. Try typing library function or enum and enjoy!

At least, it worked for me.

Solution 2 - Xcode

Code completion also stopped working for me in Xcode 8.2.1, and no amount of clean-up, derived data throwaway or restart fixed it. After a while, I realized code completion was only broken within the extension scope I was working on. If typed manually, the code would be correctly highlighted and would compile fine, so it was not an issue of the source throwing off whatever parser is in charge of code completion.

Here is the specific context in which it happens, in this very simple example:

struct SomeStruct {

    static let foobar1 = {
        return NSBezierPath()
    }()

}

extension SomeStruct {

    static let foobar2 = {
        return NSBezierPath()
    }()

}

Code completion works fine within the implementation block of foobar1, but not for foobar2. It's the presence of a static let within an extension that seems to trigger it. The issue appears for both struct and class.

Looks like a bug with Xcode, so the only workaround for me was to move foobar2 into the main definition of SomeStruct.

Solution 3 - Xcode

Just restarting Xcode worked for me.

Solution 4 - Xcode

Just clean and build your app once on Generic iOS Device, it might be due to some compile time issue, which disables the intelligence, I am seeing this bug since Xcode 8.2.1.

Solution 5 - Xcode

What worked for me was deleting derived data:

Xcode Preferences -> Locations -> arrow symbol takes you to "Derived Data" -> delete folder

Solution 6 - Xcode

I have had major issues with this as well. For me the code completion and formatting gets lost on my current working source file when ever I do a compile. If I go back and switch to a different tab and come back, after a second or two it starts working again. Sometimes even that doesn't work and I have to stay in the same tab and open up a different file and then navigate back.

Even those methods fail if I leave Xcode open and put the computer to sleep for a few hours and come back. When that happens I have to quit Xcode, sometimes Force Quit it, and then after getting back in do the steps above. But I have had to mess around with it after every single compile or compile and run I do. Haven't tried 8.3 beta yet.

Solution 7 - Xcode

I had the same issue where the "indexing" did not work. As I was using a pod and static libraries. What I did just rebuild the static libraries separately.

Hope this helps.

Solution 8 - Xcode

If you have any large static literals, try commenting them out. Those can sometimes trip up the compiler.

Solution 9 - Xcode

Nothing else worked for me, but this bizarre approach did:

  1. Quit Xcode
  2. Go into your home directory, which if you're like me, is riddled with empty directories with garbage names
  3. rmdir * (as long as you leave the tags off, this will kill only empty directories, which is what you want)
  4. Launch Xcode, happy times again

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionethanfox27View Question on Stackoverflow
Solution 1 - XcodeChinmayView Answer on Stackoverflow
Solution 2 - XcodecharlesView Answer on Stackoverflow
Solution 3 - XcodeDisplay NameView Answer on Stackoverflow
Solution 4 - XcodeRein rPaviView Answer on Stackoverflow
Solution 5 - Xcodeuser1105951View Answer on Stackoverflow
Solution 6 - XcodebdepazView Answer on Stackoverflow
Solution 7 - XcodeKaren LusinyanView Answer on Stackoverflow
Solution 8 - XcodeEdenView Answer on Stackoverflow
Solution 9 - XcodeMatt ChannonView Answer on Stackoverflow