Lexical or Preprocessor Issue error (UIKit/UIKit.h file not found)

Maple picture Maple · Aug 20, 2012 · Viewed 9.9k times · Source

I've read the other question in regards to lexical and preprocessor issues and I've tried to use what helped solve their problems. Unfortunately, none of those solutions have helped rectify the problem. This error came out of nowhere and I'm not sure what I can do, other than what read, to fix this. Please help!

Here is the code in which I get the error:

#import <UIKit/UIKit.h>

@interface scanshootViewController : UIViewController
<UINavigationControllerDelegate, UIImagePickerControllerDelegate>

{
    IBOutlet UIImageView *imageView;
    UIImagePickerController *imagePicker;

}

@property (nonatomic, retain) UIImageView *imageView;

-(IBAction) btnClicked:(id) sender;

@end

Answer

David H picture David H · Aug 20, 2012

Try removing the "Derived Data" folder for your app - you can find it in the Projects tab of the organizer. One you get there in the finder, close the project in Xcode, delete the folder, reopen the project, and try to build. If that does not do it close project, remove every directory in your project file that starts with your userID (or just rename them), reopen, rebuild.

EDIT: a few more suggestions

1) Look at the Target's "Use Standard System Header Directory Searching" and make sure its YES.

2) In your .pch file, you should have something like:

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>

Try adding "Hello" on a line by iteslf under OBJC to verify that when you build, you get here (and get a fatal error) - this will prove whether OBJC is defined.

3) Create a totally new project - iOS one view. Make sure it builds and runs (if not Xcode is frogged). Then open that project Build Settings along side your projects', and look line by line top see what is different.

4) If all else fails, move your project to a different directory, create a new one, then add all the files back into the new project. This is obviously the worst possible solution.