Xcode 9 Autocomplete Not Working 100% - Partially

2020-02-16 06:27发布

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?

enter image description here

30条回答
狗以群分
2楼-- · 2020-02-16 06:37

Just lost a day trying to solve the autocomplete nightmare of Xcode (9.2). Deleting derived data seemed to work briefly then things reverted. Reboots etc and other suggested voodoo failed to make a difference.

I gave up and download the 30 day trial of AppCode from Jet Brains. Autocomplete worked fine there and this maybe coincidence but it then started working again in my project in Xcode. Can't guarantee that it'll keep working...

查看更多
Melony?
3楼-- · 2020-02-16 06:37

My case might appear too specific to help, but it might give someone an idea of how to solve broken auto-completion. Xcode 10.2.1.

In my case, auto-complete stopped working entirely and non of these other answers helped me. In addition, the fan on the computer could be heard to go louder indicating something was overworking (no other apps running), it should be noted I was editing on a MacBook Pro laptop. It seemed to be linked with the editor struggling to parse the equation I'd written:

switch mtype {
    case .indeterminate:
      newPosition.x = (frame.width - mainFigureText.frame.width) / 2
    case .right:
      newPosition.x = (((frame.width / 2) - mainFigureText.frame.width) / 2) + (frame.width / 2)
    case .left:
      newPosition.x = (((frame.width / 2) - mainFigureText.frame.width) / 2)
 }

I was looking to animate a text view left, right, or to the middle depending on user prefs. The newPosition is a CGPoint that the text will animate to. Anyway, I split the equations up and all of a sudden auto-complete started working and the fan went quiet! I've been able to recreate this specific problem more than once by re-typing the above code and then replacing it with:

let halfFrameWidth: CGFloat = frame.width / 2
let middleLeft = (halfFrameWidth - mainFigureText.frame.width) / 2

switch doseType {
    case .right:
      newPosition.x = middleLeft + halfFrameWidth
    case .left:
      newPosition.x = middleLeft
    default:
      newPosition.x = (frame.width - mainFigureText.frame.width) / 2
 }
查看更多
何必那么认真
4楼-- · 2020-02-16 06:38

I had the issue with 100% not working auto-complete, none of written here helped. One thing I noticed – it was broken right after adding some entities into .xcdatamodel file, which have codegen class definition by default.

So I wasn't surprised when using old-style codegen none (and generating classes of course) fixed the issue immediately, even without restarting the xcode.

enter image description here

查看更多
Ridiculous、
5楼-- · 2020-02-16 06:40

Use Command + B
or Command + R to Build or Run the project
Xcode sometimes messes up ;)

查看更多
女痞
6楼-- · 2020-02-16 06:42

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

查看更多
在下西门庆
7楼-- · 2020-02-16 06:43

This can happen when the file is not a member of the Target. Open the file where autocomplete is not working and show the the "Utilities" tab in the top right of Xcode (blue in the screenshot below). Screenshot of Xcode top right view buttons

Screenshot of Xcode Target Membership options

Ensure your Target (typically your app's name) is checked. Autocomplete should work almost instantly without restarting Xcode, cleaning, or deleting Derived Data.

查看更多
登录 后发表回答