Xcode 7.3自动补全太让人沮丧了

Xcode 有一种新的自动补全系统。可能会有用,因为它不仅检查名称的开头等。但是我发现它经常根本找不到类名或者常量名等等。我需要自己输入全名。总的来说,我发现它使我的生活更加艰难,编码更加耗费时间。有没有办法让它回到以前的工作方式?

17744 次浏览

It seems that clearing the checkbox "Enable type-over completions" in XCode -> Preferences -> Text Editing does the trick. At least in my case autocompletion fell back to a sort of old way, so it could autocomplete the class name that I had to type in manually before that.

it doesn't find a class name

As a work-around, you can try to press Command + Shift + K and Command + B Several times,it works temporarily.

This is by no means an adequate solution, BUT it has allowed me to (barely) maintain my sanity the past few days: After every build, you need to trash your Derived Data folder. You can find this folder in Xcode > Preferences > Locations > Derived Data. Just trash the whole thing and it'll kick off a re-indexing step that should restore proper autocomplete functionality. Unfortunately, I've found that once I build, the autocomplete behavior reverts to its broken state.

Xcode 7.3.1

  1. In Xcode > Preferences > Text Editing

    uncheck Enable type-over completions

  2. restart Xcode

I have the impression that some 'parts' of autocompletion simply fail after a while. I use to restart the Mac to get it back working. But sometimes it fails quite soon again. Maybe the answer of @Alex Bykov combined with a restart will do the trick.

Anyway: auto-completion of Xcode always was crap. AppCode used to get it much better. Unfortunately not yet with swift.

Xcode 7.3.1

I will share another posible reason, that after couple of days we found out. We have multiple schemes, and in one of them, the bridging header was importing a file that didn't exist anymore. So, it didn't break while compiling and running (the header belongs to another scheme) but it caused the autocompletion to break (couldn't find any objective-c class).

Hope it would help someone!

I ran into this issue while trying to make an OS X app and I was able to fix this issue by making sure that the Xcode 7.3 documentation and the OS X 10.11.4 documentation was actually downloaded. Doing this fully restored my autocomplete functionality. My full instructions are below as well as in my answer to a similar question: https://stackoverflow.com/a/39420664/3444925

I had this problem myself and after looking through all the other similar questions & answers about this, I couldn't find a solution. However, I finally found what worked for me.

Go to Xcode -> Preferences -> Components. There you will probably find a screen that looks like the following:

enter image description here

This shows that the documentation has not has not been downloaded and therefore, any attempts to re-index or re-build the application without downloading the documentation would prevent you from being able to use the autocompletion functionality.

Once I downloaded the Xcode 7.3 Documentation and the OSX 10.11.4 Documentation, this was enough for me to get the autocomplete functionality back (I was trying to build an OS X app, so feel free to download as much documentation as is relevant for you).

I didn't run into this until I created a couple of new class files. Other classes worked fine, but autocomplete would NOT work for anything in the new files...

FIX (for me) - I had to add those files to ALL of my targets, including the unit test targets even though I wasn't using them yet.

just open Xcode derived data folder and delete the folder

/Users/yourUserName/Library/Developer/Xcode/DerivedData

then restart Xcode, now autocompletion works like a charm

Closed Xcode, opened Xcode, let it index, it worked.

After having tried different methods:

  • Delete Derived Data
  • Switching Module Enabled off in Build Settings
  • Full Clean
  • Relaunch

Only this worked:

  • Find any commented out (/* abc */) code after @end in your files and delete.

Credit to Max_B: https://forums.developer.apple.com/thread/7439

In my case, other projects were auto-completing correctly. If all your projects fail to correctly predict code, then it might be a different issue, and the other answers might work.