Reputation: 2441
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?
Upvotes: 152
Views: 75637
Reputation: 616
I faced the same problem in Xcode 11.3.1. In my case The issue was cause due to duplicate file names / Deleted file name. Better to run the application once and check whether there are any deleted files/classes so that you will get a syntax error.
Upvotes: 1
Reputation: 1764
In the right "File Inspector," try toggling on an off the "Target Memberships." If you are creating a multiplatform project, try toggling (macOS).
Autocomplete should work immediately without restart.
Upvotes: 0
Reputation: 3074
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;
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
Every .swift
and .m
file in the project should be in this list or it won't autocomplete in those files.
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
* In Swift 4 private became stricter than fileprivate
In Xcode 12 there have been significant improvements in how often deleting derived data is necessary (though freezing has increased).
Upvotes: 37
Reputation: 21
with swiftUI try to extract your subViews, otherwise the autocomplete will not work.
If you have a lot of not extracted subviews, the autocomplete will stop working
Upvotes: 0
Reputation: 630
Here's a bit of workaround but works.
Clean the project... Command + Shift + K
Clean the build folder... Command + Shift + Options(Alt) + K
Delete derived data for the project... This can be done with the help of this link:
Close XCode.
Reopen XCode (let the indexing complete) and Build the project... Command + B
Once it will be done with building, The suggestions will be back. I have tried it twice.
Update:
Sometimes the issue can be as simple as Duplicate file names. Carefully check if any new file names added by you are conflicting with older files.
In Xcode 11.4, even if you move an existing file to another group, the suggestions disappear. This can be cured simply by restarting Xcode.
Upvotes: 11
Reputation: 5058
goto underneath directory and delete all folders on it.
{Your User}/Library/Developer/Xcode/DeriveData
It worked for me.
Upvotes: 2
Reputation: 8568
Back Slash in folder name breaking the autocompletion feature, If this is the case remove it and build again.
Upvotes: 4
Reputation: 2662
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).
Ensure your Target (typically your app's name) is checked. Autocomplete should work almost instantly without restarting Xcode, cleaning, or deleting Derived Data.
If it is already checked, make sure to uncheck and recheck it again. For me, it did the trick.
Upvotes: 25
Reputation: 505
Had the same problem with Xcode 11.3. Nothing above didn't help, it turned out that I had build errors. Just fix the build errors and autocompletion will work again.
Upvotes: 0
Reputation: 107
Xcode 11.3, macOS catalina
process parsecd achieve 100% of cpu, so kill it helps me
Upvotes: 2
Reputation: 1
This works for me:
Save a backup of all the project file somewhere.
Delete the project.
Create a new project and add all the files.
And it automagically works.
Upvotes: -6
Reputation: 2273
In my case (Xcode 11.1), It happened when I stopped Xcode auto-indexing with this command defaults write com.apple.dt.Xcode IDEIndexDisable -bool true
.
So I rolle back it with defaults write com.apple.dt.Xcode IDEIndexDisable -bool false
.
then restart macOS and run again Xcode.
Upvotes: 0
Reputation: 441
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:
That solution helps me now. May be useful for others 😉
Upvotes: 34
Reputation: 410
If you have issue with weird completion/auto-completion/intellisense (not showing default stuff like delegates and datasource protocols methods) just change your target (e.g. from simulator iPhone 8 to real device), build the project and switch back to your original target.
Similar with issues with Interface Builder (storyboards) not showing anything, but only "nothing selected" whenever you select any part of the view. Just switch to other Xib/Storyboard (or even create new), check if it works there and switch back.
These workarounds worked for me in both cases (had both issues in one day with one project on Xcode 10.2.1). From what I've seen all over internet forums it seems these are bugs never fixed since Xcode 6.x or so.
Cheers!
Upvotes: 0
Reputation: 9131
With Xcode 11.1, simply performing Clean Build Folder
or deleting derived data was not enough to fix autocomplete.
Only after restarting my Mac, everything was back to normal
Upvotes: 0
Reputation: 1306
I would like to add one more to the pile of solutions, because it is the only one that worked for me and is nowhere to be found here.
Xcode normally comes with two default build configuration for every project. Release
& Debug
. I have an extra one for my unit tests called Testing
. In Xcode 10.1, 10.2, 10.3 and 11 beta, the new build system does not seem to like it and will only auto-complete if you either use Release
or Debug
. Any custom build configuration breaks auto-completion in mixed (swift + objc) project with unit tests.
Upvotes: 1
Reputation: 13993
This can also happen if you redundantly named your files. For example,
Data.swift
Data.swift
Upvotes: 12
Reputation: 4808
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.
Upvotes: 0
Reputation: 1953
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
}
Upvotes: 1
Reputation: 6425
I'm using Xcode 10.2 and I had the same issue.
This answer from axel helped me to fix.
Anyway, I'm going to describe a bit more:
YourProject.xcodeproj
by clicking with Right Mouse Click and open Show Package Contents
xcuserdata
and delete your youruser.xcuserdatad
If you have also the xcworkspace
(if you already have any pods installed) then do step 3&4, if not then just skip step 3&4:
YourProject.xcworkspace
by clicking with Right Mouse Click and open Show Package Contents
Go to xcuserdata
and delete your youruser.xcuserdatad
Quit Xcode
rm -rf ~/Library/Developer/Xcode/DerivedData
Upvotes: 13
Reputation: 11
Suggest completions while typing
in Xcode -> Preferences -> Text EditingUpvotes: 1
Reputation: 4961
Use Command + B
or Command + R
to Build or Run the project
Xcode sometimes messes up ;)
Upvotes: 2
Reputation: 2916
I added here what was going on in my project just in case it can help someone else... I had 2 files with the same name and I didn't realise.
Upvotes: 3
Reputation: 9925
Build errors can break the autocompletion feature in Xcode.
Upvotes: 0
Reputation: 1453
After a long time of searching, I finally fixed the issue for me. In Xcode > Preferences > Text Editing, in "Code Completion", I had "Use Escape key to show completion suggestions" checked for some reason. As soon as I unchecked this box, auto completion worked like a charm, without even needing to restart Xcode! (Xcode 10)
Upvotes: 6
Reputation: 826
Problems mostly because there are missing location of some files in project navigator (build errors)
Project Navigator
paneOr you can:
Hope this helps
Upvotes: 2
Reputation: 5331
This Link helped me. Open the Build Settings & fill the framework search paths. See the below image.
Upvotes: 0
Reputation: 1527
The only time auto-complete doesn’t work is when the source code type for the file is not set to Objective-C or when you’re writing in another language (even if only a little snippet of, say, C).
It also doesn’t work if there is a syntax error on or above the line you are editing. A missing curly brace at the end of a method call—even if it’s not in the file you’re editing–will prevent auto-complete from obtaining the necessary context to suggest relevant commands. So will a missing file (shown in red in your list of files), even if that’s not the file you’re working on.
When it does that, attempt a build to locate errors, and then fix them.
Upvotes: -1
Reputation: 3607
It seems to be file specific in my case (Xcode 9.2) For me the fix was:
Finally after 3 hours of trying everything - autocomplete works as it should.
Upvotes: 2
Reputation: 990
For me, the problem occured when I discarded all the changes of one file (under Source Control > Commit), which effectively deleted the file. This is what I wanted and I thought that the file and all references to it would be delted too.
However, there was still a reference to the file (shown in red) in the Project navigator. Deleting the (now non-existant) file in the Project navigator magically brought auto-completion back.
No amount of cleaning, deleting derived data, etc helped. I only realized the deleted file was still showing when I tried to build my project, which of course failed because it couldnt find that file.
Hope this will help someone save 30 minutes :)
Upvotes: 1