Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class defined without specifying a base class. Cannot find interface declaration for UIViewController

I have a created a new project and added a new class called MyViewController. My code compiles fine when MyViewController is a subclass of NSObject but when I change it to inherit from UIViewController I get these two error messages:

Class "MyViewController" defined without specifying a base class

and

Cannot find interface declaration for "UIViewController", superclass of "MyViewController".

What is wrong with my header file?

MyViewController.h

#import <Foundation/Foundation.h>

@interface LBAHypnosisViewController : UIViewController

@end
like image 579
cvinette Avatar asked May 17 '26 07:05

cvinette


1 Answers

Foundation doesn't include UIViewController, which is part of UIKit. Add this to your header file.

#import <UIKit/UIKit.h>

You may notice that many projects include both Foundation and UIKit in their prefix header. This automatically includes them in every file. Older versions of Xcode would do this for you when creating a new project.

like image 185
CrimsonChris Avatar answered May 18 '26 20:05

CrimsonChris