Xcode 8.2 Code Completion Not Working

后端 未结 9 725
情书的邮戳
情书的邮戳 2020-12-08 05:57

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 st

相关标签:
9条回答
  • 2020-12-08 06:55

    What worked for me was deleting derived data:

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

    0 讨论(0)
  • 2020-12-08 06:57

    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.

    0 讨论(0)
  • 2020-12-08 07:01

    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
    0 讨论(0)
提交回复
热议问题