Xcode 9 Autocomplete Not Working 100% - Partially

2020-02-16 06:03发布

问题:

This morning, Xcode 9.0 (9A235) shows a new/strange Auto Complete box that is not at all what it used to be. How do I get the full auto-complete box so that autocomplete looks like how it usually does?

回答1:

Try:

  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!


回答2:

Deleting the DERIVED DATA folder seemed to fix my issue. Thanks to this post: swift println() not showing autocomplete options while writting code



回答3:

Things to try:

1

Run this command in the project directory if you use cocoapods:

rm -rf ~/Library/Caches/CocoaPods;
rm -rf Pods; rm -rf ~/Library/Developer/Xcode/DerivedData/*;
pod deintegrate; pod setup; pod install;


2

Clean Cached Data

Clean the Project -> Cmd+Shift+K

Clean the Build Folder -> Cmd+Shift+Option+K

If you skipped step one:
Delete Derived Data
Xcode Preferences -> Locations ->
Arrow Symbol Takes you to DerrivedData -> Delete Folder


3

Check your Build Phase's Compile Sources.

Every .swift and .m file in the project should be in this list or it won't autocomplete in those files.


4

Optimize your Editor:

Use fileprivate on every class property and function that you can to reduce the scope of the Compilers work per item.

Write modular/OOP code so you have less code for the compiler to read.

Avoid using Type Inferance when the result is a complex calculation, and try to break down complex calculations into let this = smallerOperation statements



回答4:

Xcode Version 11.0 (11A420a)

I have tried the solution from Lal Krishna for Xcode V11.0. It worked a few times but later I got no result.

I found one solution. You must delete two files:

  1. Library/Developer/Xcode/Derived Data (as described before)
  2. Library/Developer/Xcode/UserData/IDEEditorInteractivityHistory

That solution helps me now. May be useful for others