13

do you face also the problems with Xcode 4 autocomplete feature that used to work great on version 3.x.x?

I've imported in the Prefix some classes and Xcode doesn't want to help me with the code entry. I have to manually add above @implementation

import "myclass.h"

To make Xcode help me entering the class name, properties, methods, macros defined in the myclass.h. On 3.x.x I could import those important classes once in the prefix and the autocomplete feature worked without any problems anywhere in the project.

Sometimes Xcode goes even more stupid, it doesn't want me to help typing the classes like UIButton, UIView and the common method like addTarget:action:forControlEvents: for my buttons.

Do you also has the problems I mentioned in the Xcode 4, any solutions?

Community
  • 1
  • 1
Chris Rutkowski
  • 1,774
  • 1
  • 26
  • 36

5 Answers5

16

I was able to correct this issue by setting Precompile Prefix Header to No in the build settings.

rebelzach
  • 2,670
  • 1
  • 17
  • 14
3

EDIT 3: Note that this indexing issues has mostly disappeared in recent versions of Xcode (4.1 for sure, latest pre-Lion 4.0.x I think), and that I do not use this workaround anymore, using pch... And in fact not using Xcode anymore... AppCode ftw! :)


An easy, but quite dirty workaround imho is not using precompiled header .pch file to do global includes, but instead go a global header .h, that you include... everywhere. That way indexing will work flawlessly...

I Know that's dirty, don't downvote me please :) I'll delete this answer as soon as someone propose something better! Which I would love.

Off-topic, but related, read somewhere llvm2 is not supposed to get a gain speed with .pch files. which kind of deprecate them.

EDIT: Just checked to be sure of my answer, latest version of Xcode (4.0.1 when writing this) looks like fixing that bug for me. Did you upgrade to latest version?

EDIT 2: Removed my global import header .h, all its references, and moved my global imports into .pch file... That doesn't work as well I expected, latest Xcode 4.0.1 improved on this part but still have some cases where it fails. (I'm working on a project with hundreds of files). Looks like cleaning index/restarting Xcode fix it. I might consider reverting to my dirty workaround...

Vincent Guerci
  • 14,379
  • 4
  • 50
  • 56
1

I found that sometimes the autocompletion gets broken when dealing with stuff defined in the prefix header. One way to get Xcode to index those again correctly is to use the touch command in the Terminal, e.g.:

touch /Users/someguy/Document/Foo-App/Foo-Prefix.pch

Or add a new line to the prefix for the same effect. Xcode then gets busy reindexing and things work again.

charles
  • 11,212
  • 3
  • 31
  • 46
1

I have found that changing compilers, building, and then changing back, and building again works relatively consistently. Wrote a post about it on my blog:

http://rhappsody.wordpress.com/2011/08/03/xcode-4-code-colouring-and-auto-completion/

aakash
  • 1,001
  • 1
  • 8
  • 10
0

I've faced the same issued as soon as I moved to XCode4. What I realised was that I needed to install iOS's documentation to have the code completion fully working.

Go to Xcode -> Preferences -> Documentation and click GET on the iOS 4.3 Documentation. In the iTunes-style status window, the download progress will be shown.

Claudio Martins
  • 617
  • 1
  • 6
  • 12