Xcode 9 Autocomplete Not Working 100% - Partially Working
Asked Answered
E

36

151

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

Expedite answered 30/9, 2017 at 15:38 Comment(4)
Deleting the DERIVED DATA Folder solved it for me. Thanks to another post. Thanks to this post: #28430130Expedite
Probably it is because indexing hasn't been completed yet.Apparatus
11.3 is a disaster regarding this issue. Often just restarting Xcode helps :/Sialagogue
https://mcmap.net/q/157689/-xcode-stuck-on-indexingLohrman
E
67

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

Expedite answered 30/9, 2017 at 17:38 Comment(1)
Clean didn't help. Only deleting a folder.Rufusrug
A
305

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!
Artis answered 11/1, 2018 at 7:2 Comment(3)
This a a bug in Xcode as always new updates creates new problems, the working solution for me is: 1- Quite Xcode. 2- wait few seconds. 3- Open Xcode but don't touch anything not even clicking somewhere in the editor. 4- Wait till indexing is finished. Autocomplete works now.Mayday
Xcode 11.4 beta (11N111s) is fundamentally broken here. Neither autocomplete nor "jump to definition" work. The suggested solution above does not resolve the issue.Spectrometer
This half worked - it went from showing "No completions" to only showing...fields but not methods? Stuff from the class but not its superclasses? Not sure.Micturition
E
67

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

Expedite answered 30/9, 2017 at 17:38 Comment(1)
Clean didn't help. Only deleting a folder.Rufusrug
F
36

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

* 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).

Faught answered 14/10, 2017 at 18:55 Comment(1)
With XCode 9.2 there isn't an Arrow Symbol anymore to the Derived Data Folder. Thanks for the fileprivate tip. The nightmare continues...Inerney
B
34

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 😉

Borras answered 27/10, 2019 at 16:12 Comment(1)
tried to do that with new Xcode 13.2.1 and these not help unfortunately.Romany
N
25

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.

If it is already checked, make sure to uncheck and recheck it again. For me, it did the trick.

Normand answered 1/10, 2017 at 18:36 Comment(2)
only opening that page and closing worked. I'm confused. Thanks btw.Opposable
It worked on xcode 10. The file was indeed already member of the target. I had to un-check then check it again into being recognised as such.Headwind
Y
13

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:

  1. Go to YourProject.xcodeproj by clicking with Right Mouse Click and open Show Package Contents
  2. Go to 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:

  1. Go to YourProject.xcworkspace by clicking with Right Mouse Click and open Show Package Contents
  2. Go to xcuserdata and delete your youruser.xcuserdatad

  3. Quit Xcode

  4. Delete Derived Data by using Terminal:

rm -rf ~/Library/Developer/Xcode/DerivedData

  1. Open Xcode and check if it works.

enter image description here

Ytterbia answered 15/4, 2019 at 8:47 Comment(0)
N
12

This can also happen if you redundantly named your files. For example,

Data.swift

Data.swift

Notion answered 8/8, 2019 at 3:6 Comment(0)
I
11

Here's a bit of workaround but works.

  1. Clean the project... Command + Shift + K

  2. Clean the build folder... Command + Shift + Options(Alt) + K

  3. Delete derived data for the project... This can be done with the help of this link:

    How can I delete derived data in Xcode 9?

  4. Close XCode.

  5. 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.

Indignant answered 16/12, 2018 at 8:15 Comment(0)
B
7

Removing the file from the Test Targets fixed my problem.

Bowline answered 21/2, 2018 at 15:4 Comment(0)
L
6

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)

Larval answered 14/10, 2018 at 0:26 Comment(0)
R
5

Please try doing this:

Select the file >> check if the file is added to UITesting or UnitTesting targets (File inspector -> Target Membership). If so, please uncheck those two and make sure only the project target is selected. Then build and try if autocomplete is working fine.

This worked for me. Hope it help someone.

Returnee answered 6/6, 2018 at 5:34 Comment(0)
T
4

For Xcode 11.4 (11E146)

Back Slash in folder name breaking the autocompletion feature, If this is the case remove it and build again.

enter image description here

Taiga answered 11/4, 2020 at 16:52 Comment(0)
H
3

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.

Hydrotropism answered 4/2, 2019 at 11:30 Comment(0)
E
2

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...

Earring answered 12/2, 2018 at 9:21 Comment(0)
B
2

It seems to be file specific in my case (Xcode 9.2) For me the fix was:

  1. Delete problem file (remove reference)
  2. Clean and Build
  3. Add file back into the project (I did not check test targets)
  4. Build again

Finally after 3 hours of trying everything - autocomplete works as it should.

Burkholder answered 8/7, 2018 at 0:23 Comment(1)
what is the problem file?Mcgriff
C
2

Problems mostly because there are missing location of some files in project navigator (build errors)

  1. Press command+1 to open Project Navigator pane
  2. Check if there are any missing files

Or you can:

  1. Delete DerivedData (command+shift+K)
  2. Clean build folder (command+shift+option+K)
  3. Press build again (command+B)
  4. You should see build error that Xcode could not find some files that prevent build tool to process auto complete.
  5. Correct and fix any missing files that you see.

Hope this helps

Camilia answered 3/10, 2018 at 4:17 Comment(0)
W
2

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

Warrantee answered 11/3, 2019 at 7:21 Comment(0)
K
2

Xcode 11.3, macOS catalina

process parsecd achieve 100% of cpu, so kill it helps me

Karli answered 17/12, 2019 at 12:38 Comment(0)
B
2

goto underneath directory and delete all folders on it.

{Your User}/Library/Developer/Xcode/DeriveData

It worked for me.

Brood answered 22/5, 2020 at 8:37 Comment(0)
S
1

For me it was happening in my test file, because it wasn't part of a target for some reason. Setting it's target membership solved the issue.

Stylopodium answered 22/5, 2018 at 18:6 Comment(0)
F
1

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 :)

Fourthclass answered 21/6, 2018 at 10:48 Comment(0)
C
1
  1. check whether you selected the Suggest completions while typing in Xcode -> Preferences -> Text Editing
  2. navigate to user->Library->Developer->Xcode->DerivedData in Finder and delete the DerivedData folder
Cranach answered 20/3, 2019 at 1:32 Comment(0)
T
1

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
 }
Typeface answered 24/6, 2019 at 11:1 Comment(0)
N
1

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.

Nomism answered 20/8, 2019 at 8:4 Comment(0)
G
1

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.

Gallinacean answered 17/4, 2021 at 10:45 Comment(0)
D
0

This Link helped me. Open the Build Settings & fill the framework search paths. See the below image.

enter image description here

Debroahdebs answered 29/8, 2018 at 7:51 Comment(0)
P
0

Build errors can break the autocompletion feature in Xcode.

Percutaneous answered 22/10, 2018 at 7:4 Comment(0)
C
0

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

Cote answered 26/7, 2019 at 20:57 Comment(0)
M
0

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

Mosely answered 9/10, 2019 at 21:44 Comment(0)
A
0

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!

Anticatalyst answered 16/10, 2019 at 11:55 Comment(0)
B
0

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.

Booth answered 10/11, 2019 at 7:30 Comment(0)
A
0

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.

Augite answered 21/12, 2019 at 15:29 Comment(0)
K
0

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

Kavanagh answered 25/12, 2020 at 17:32 Comment(0)
H
0

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.

Heisser answered 26/1, 2021 at 8:25 Comment(0)
M
-1

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.

Microsurgery answered 28/6, 2018 at 20:18 Comment(0)
P
-6

This works for me:

  1. Save a backup of all the project file somewhere.

  2. Delete the project.

  3. Create a new project and add all the files.

  4. And it automagically works.

Paralytic answered 24/11, 2019 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.