I've noticed that while editing header files, XCode does not auto-suggest header files to import or classes from imported files unless the file you are editing is itself imported by some file that is included in the target.

I kind of get the reasons for this, but it's super lame. I'm very happy to take the trade off of disappointment at compile time (oops! that wasn't a class that I could import) for the benefit of saving a ton of time while writing headers.

By the way I'm aware that I can use forward class and protocol declarations but this is not helpful because I often need to use something whose name I've not committed to memory. Once I know the thing to forward-declare, then I will!

Is there any way to get XCode to be more liberal about this?

Edit: with pictures

Here's what I see in a header file included by an implementation file that is added to a target when I type the letters "#i":

before

Now I comment out the include of the header I was editing

comment

Now here's what I get - but autocomplete still works

after

When I make a new protocol, of course it is not imported by some implementation file (because it is new and it is not a class, so there is no associated implementation file already created).

new protocol

So autocomplete of imports (and classes) doesn't work... until I import it from an implementation

import protocol

And now autocomplete works

yay

0

There are 0 answers