Lost completion in #import "myFile.h"
Asked Answered
L

2

21

Since I had Xcode 4.4, I have lost the completion when I want to import file on my classes. I have to write the file entirely (The problem appears only in the import scope, it works elsewhere)

Has anyone the same problem and know how to figure out ?

Loiseloiter answered 27/7, 2012 at 12:24 Comment(7)
I have this problem sometimes with Xcode 4.3Ramakrishna
same problem... really inconvenient, hoping for someone to save the worldCoarsen
happened to me once, but now working again. Please file a bug report with Apple.Mcwherter
Did you tried to close the project and to delete the project in the Organizers project area?Darice
Rather than say "I have it too", why not just upvote the first person you agree with?Maryleemarylin
I doubt this would resolve it but it might be a problem with how the project is indexed by Xcode. Try cleaning the project and then clean the project folders (hold down alt while accessing the project menu and you'll see it replace the "clean" menu entry)Stavropol
Check this thread: #5432001Sloan
L
27

Go to your project --> build settings --> User Header Search Paths and add $(SRCROOT)

That works for me.

Edit (another solution) : Sometimes I lost autocompletion randomly in my import scope. I fix it by typing the double quotes #import "" before typing my class between with the autocompletion.

Loiseloiter answered 22/8, 2012 at 8:17 Comment(5)
Need to enable the recursive search by clicking on the checkbox on the left of this path.Scarito
Rock on ! I should have searched this wayyyy before :OEudemonism
Second solution works for library headers, too; type #import <> first and then fill in the bracketed part.Whiteness
Second solution is a winner. Cheers!Beitris
Nothing worked for me except typing both open and close quotes first. I'm on XCode 7.2 and have been experiencing this problem for a long time.Venge
B
8

Apparently this is related to having your files inside subfolders. It seems that while previous versions of Xcode's codesense would list any headers added to your project, version 4.4 only lists the ones in the topmost folder in your project...

The solution I've found is to include those subfolders in the project's "User Header Search Paths".

For example, if you have a folder structure like this:

Source/
  Example/
    Util/
      util.h
  Example.xcodeproj

By default, when you type

#import "u|"

you'll get the suggestion for the Util folder. If you let it complete that and continue typing:

#import "Util/u|"

you'll get the util.h suggestion.

To get the usual autocomplete behavior, go to your project --> build settings --> User Header Search Paths and add Example to the list (double click on the setting, click the "+" button, write Example and make sure to turn on the checkbox to the left). When you close the little pop up, your setting should read something like Example/**, which means it's including Example and every subfolder.

The new behavior (feature? bug?) was driving me crazy. Hope that helps.

Baillargeon answered 11/8, 2012 at 20:25 Comment(2)
To include all files in your source, use this : "$(SRCROOT)/**". This works great, it's been driving me crazy for weeks, thanks!!Translation
This actually didn't work right of the bat for me, and was driving me insane... I had to remove the path that I had already set in the "Header Search Paths", and then add it in the "User Header Search Paths". Now, everything works properly.Wacke

© 2022 - 2024 — McMap. All rights reserved.