0

I am getting an error:

Error: Lexical or Preprocessor Issue: 'Constants.h' file not found

When the code is run, the issue disappears and the app works fine.

How can I fix this?

3
  • Is the file called constants.h or Constants.h?
    – trojanfoe
    Dec 6, 2011 at 7:44
  • Has it been dragged into your project as well?
    – Luke
    Dec 6, 2011 at 8:08
  • Had this once, I suspect it is due to the indexing in xcode, I just closed and reopened xcode and it was gone.
    – gregory
    Dec 6, 2011 at 11:03

1 Answer 1

0

two things:

  1. Do a product "clean" (CMD-SHIFT-K)
  2. Avoid over-including headers from headers.

This involves using forward declarations whenever possible in headers (only #include another header if you are extending the class or implementing a protocol in that header). Use forward declarations for classes and protocols in your headers; then do the actual #import in your .m files.

@class SomeTypeINeedWhichIsAClass;
@protocol SomeProtocolWhichIsUsedInMyMethodSignatures;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.