unknown type name in objective c unknown type name in objective c objective-c objective-c

unknown type name in objective c


I figured out, that the same error appears if you have an import-cycle:

Class_A.h: #import "Class_B.h"

Class_B.h: #import "Class_A.h"

To fix: look for any imports of the offending class (the error tab is your friend, expand the relevant error for a list of imports). Remove #import's accordingly


This problem happen to me once.

I was importing the "APPDelegate.h" in my h file and in my APPDelegate.h I was importing the file too (it shouldn't be a problem but...)

What I did: I changed the Import from my own .h to .m and it worked :)


As others have mentioned, this is indeed caused by cyclic imports. To fix this remove the imports in one of the classes. But sometimes this is not sufficient. If the classes depend on each other, simply forward-declare the one class in the other:

Class A:

#import <UIKit/UIKit.h>@class B; //<- this is essential here@interface A: NSObject@property(nonatomic, strong) B *b;//...

In class B we have:

#import "A.h"@interface B: NSObject@property(nonatomic, strong) A *a;