Xcode 4 code sense is not working
Asked Answered
E

13

77

I am running a "old" Xcode 3 project in Xcode 4 and code sense is not working for my own classes. I have tried following:

  • Clean/rebuild
  • Remove Derived Data
  • Installing 4.3 documentation
  • Restart

Without any luck.

Sometimes the code sense works but mostly I just get "No Completions".

Equator answered 25/3, 2011 at 10:55 Comment(8)
have you installed the update to 4.0.1 which was released yesterday? The Fixed a bug that prevented indexing of some projects from the release notes sounds like it could have to do with your problem.Clingy
Installed 4.0.1, removed old index (derived data), cleaned, rebuild, unfortunately still the same. I think the problem has to do with the update from the old 3 project, I have som new projects created in xcode 4 and they seem to work.Equator
Just to update, today everything seems to work much better. Maybe the 4.0.1 update did the trick after all.Equator
Sorry to say, this is starting out to be a farce, xcode code sense is not working as expected.Equator
I have exactly the same problem. 3.2 project in XC4. 4.0.1 didn't fix it. Also tried all the other 'quick' fix options (clean, delete deriveddata, install doccs etc) to no avail. Sadly I think the only option at the moment is to generate new project in XC4 and copy all the files over - a major hassle with a large project :(Undershoot
Just a side note. I am trying out appCode for some of my projects and it is still missing some major features such as targets and subprojects. But it is working extraordinary well for simple projects, and if you have experience from intellj or resharper you will find your self at home again. So I am not really affected by this bug for the moment.Equator
I'm having the same problem, my conde sense is not working for a c++ library (Box2d)Slipcase
Duplicate of #1627533 ?Quartic
T
127

Try this:

Open Organizer then Project Tab.

Clear the "Derived Data". Xcode should re-index your project then and code sense should work. At least worked for me.

Thomasinathomasine answered 5/6, 2011 at 13:45 Comment(3)
I tried that, and it didn't help (as I already stated in my question). I don't have this problem any more since I don't use xcode any more, I have switched to app code.Equator
This fixed the problem for me. Latest Xcode Version 4.3.1 (4E1019). Thank you.Lavena
This not solved my problem, look at @Chris solution for this issue , nice solutionFroggy
S
107

I know this is late, but for reference: http://sealedabstract.com/code/when-xcode-4s-code-completion-autocomplete-breaks/

  • Close the project, leaving XCode still running.

  • Open XCode’s Organizer window, go to the Projects Tab, select the correct project, and hit the Delete button next to “Derived Data”.

  • Quit XCode.

  • Navigate to your project’s .xcodeproject file in Finder. Right-click, choose “Show Package Contents.”

  • Leave the project.pbxproj file, but delete the project.xcworkspace file, any .pbxuser files, and the entire userdata folder.

  • Open the project in XCode. You will see XCode riding high on the CPU usage for around 10-60 seconds, depending on the size of your project. The activity window will say “Indexing”

  • When your CPU spike returns to earth, code completion will be working again.

There's a lot of deleting going on there so please be careful, but this definitely worked for me.

Sigvard answered 17/11, 2011 at 10:51 Comment(8)
Thanks for the link. For what it's worth, I found that I didn't have to explicitly delete any files to get code sense working in Xcode 4.2.1; deleting the "Derived Data" via the Organizer window (i.e. your first three bullets) was sufficient. Thanks.Ezequieleziechiele
This worked for me, but, as a note, you should try opening the Organiser window and clearing DerivedData and quitting & reopening Xcode first, before deleting any other files.Citizenship
Deleting appropriate files from the .xcoeproject bundle ended my suffering.Investigate
Deleting "Derived Data" fixes the problem most of the time for me, but +1 for providing a clean-slate guide for all cases!Kuebbing
Thank you so much ! This is the only thing that did the trick !Onetoone
A very good solution. Mind .svn hidden folders if you're using subversion.Hopkins
clearing derived data alone didn't do it, but deleting the files you suggested in the .xcodeproject worked. High Five!Congratulation
Got to where I was sick of hearing about deleting derived data. Thank you Chris for providing a genuine solution!Liana
D
26

I've been doing this, and it's worked multiple times for me (after trying all of the above previously).

Edit: Now I just hit space, backspace (the mac version) and rebuild... works nice. Then, remember to scroll (sometimes the colors don't show up until you scroll somewhere)

  1. Find your prefix file: "ProjectName_prefix.pch".
  2. Comment out some line. (basically change it)
  3. Build your project, doesn't matter if it fails or not.
  4. Uncomment it.
  5. Build again.

I'm betting only step 2 (modify the prefix) is what does it, but these essentially get you back to running. Suddenly everything magically recolors itself and completes functions.

Good luck if that doesn't fix it, perhaps try doing this to your dependency pch files (three20 or FB api's)

Dromous answered 20/4, 2012 at 21:55 Comment(4)
Are those included by default? I'm using xocde 5 and can't find it.Acronym
Yup same thing worked for me. Still happening even in Xcode 6Kp
My Xcode loses sense when I change to 'iOS device' instead of the simulator. No amount of derived data clearing worked. I tried this method with no hope at all, and it worked!Arrowwood
@Acronym PCH files haven't been in XCode by default for a bit.Dromous
P
5

Clearing the "Derived Data" only works temporarily for me. I have to do it and then restart Xcode like 3-4 times each day to get code sense working again.

I found out the real cause is in the Target's Build Settings. I moved everything from Header Search Paths to User Header Search Paths and it is fixed. In my case, the framework I'm working with is RestKit.

BTW, I came up with this because I was adding another project (QuickDialog) into my project and I was curious that it is using User Header Search Paths, but not Header Search Paths. Here is the difference between them.

Protohuman answered 6/7, 2012 at 10:36 Comment(4)
AHA! I've been using RestKit and only had trouble with this. I will double-check if this is the issue and report back here.Schlosser
nope. I thought it would... it seemed to help, but no, I feel like I'm just deleting the derived data less.Schlosser
I also had to delete the derived data a couple more times after that, for different builds. After that, I never have to do it again. But yeah, I still don't know how this works...Protohuman
This seemed to work for me. I'm using a static library and this autocompletion been driving me nutsDevoe
L
4

You can able to fix that issue by change build settings like this, PreCompile Prefix Headers :NO

Lamond answered 15/9, 2012 at 7:8 Comment(0)
L
3

FYI, if one file doesn't have code sense but the rest of your project does, check that its added to a target. Once I did that I got code sense back in that file.

Lettering answered 16/5, 2012 at 18:41 Comment(1)
Also delete any comment block below the @end word. This was the problem for me.Doody
R
2

It's been ages but the answer is just to move the code into a new folder and the code sense should be working now.

This happened when I added a new Objective-C Class and the code sense doesn't work only on the newly added .m and .h files (on XCode 4 latest update during this post).

Revelationist answered 21/8, 2011 at 6:54 Comment(0)
H
2

Close all xcode windows

Delete all your projects from xcode>window>organizer and restart your project. It will now sense and index your project properly.

Heterograft answered 12/3, 2012 at 7:47 Comment(0)
A
1

I wrote about it in detail here.

Basically my fix was that with localization. I upgraded from xcode 3.2.5 to xcode 4 and then screwed around with built in interface builder and turned on localization for a XIB file accidently which placed my source files in en.lproj directory. After moving them back to Classes folder it worked perfectly.

Andreeandrei answered 15/4, 2011 at 10:40 Comment(2)
Tanks, but this dosen't correspond to my problem, I have trouble with all my classes, and no I don't have my sources in a localized directory.Equator
have you tried upgrading to xcode 4.0.2. Its much more stable i thinkAndreeandrei
S
0

Again, for the sake of helping others with this issue which, in my case, happened upon upgrading to Xcode 4.3.

Of course I tried the solutions offered in this post, and none of them worked. But the suggestion to move the location of the project in Finder brought back some Code Sense, but the suggestions didn't make any sense. I ended up deleting my project and re-cloned it from the git repository.That brougt back Code Sense for me...
Splenomegaly answered 25/2, 2012 at 22:11 Comment(0)
Y
0

I open a second project in the background whenever my Xcode's code sensing stops working (it usually works the first time i open the project but after a while code sense no longer works). So what i do is to open a second project in Xcode. Xcode will start indexing the second project and magically the code sense for my main project is back.

Running Xcode 4.3.1 on Lion

Hope this helps someone.

Yield answered 25/4, 2012 at 18:21 Comment(0)
L
0

From this comment here I was able to debug the problem on my end, it seemed to be a bad -w flag that the clang preprocessor wasn't recognizing properly. Basically, running

defaults write com.apple.dt.Xcode IDEIndexingClangInvocationLogLevel 3

in Terminal increases the verbosity of the indexer, and should help you track down issues. Open Console.app and look for messages from Xcode, the search string IDEIndexingClangInvocation helped me find them.

Liaoyang answered 20/2, 2013 at 17:19 Comment(0)
C
0

For me it happened simply because the file had no target membership. If the first few answers did not work for you, go to your .m file (presumably it's this file that you're having trouble with), open the Utilities view (Edit -> Utilities -> Show File Inspector) and under "Target Membership" check the target to which you want this file to belong.

Camire answered 20/8, 2013 at 15:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.