Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Cannot find interface declaration error..." after @class

I've run into an Objective-C problem that doesn't seem to make any sense to me. I am a relatively well-versed ObjC programmer and understand the whole "forward declaration" concept, but this one has me scratching my head. So here's the deal:

ClassA is a class in my Xcode project that is project-only. ClassB is a subclass of ClassA which is public and is imported into my framework's header.

I am getting a "Cannot find interface declaration for 'ClassA', superclass of 'ClassB'..." error when building. I have already put the @class ClassA; forward declaration in ClassB.h, but that does not seem to solve the problem. When I change the @class ClassA; to #import ClassA.h, it works fine. However, since ClassA is project-only, dependent projects cannot build ClassB because it cannot access ClassA's source.

Any help would be appreciated and I hope that makes sense. Thanks!

like image 904
Grimless Avatar asked Aug 07 '10 19:08

Grimless


2 Answers

I have an answer: You must check your '#import' order. Before you use the superclass it should be imported and compiled.

like image 92
Rubycon Avatar answered Sep 22 '22 12:09

Rubycon


The problem is that you have an infinite loop in your #imports. The solution: all #imports go in the implementation file and all classes needed are declared in the .h files.

like image 35
Vitaliy A Avatar answered Sep 25 '22 12:09

Vitaliy A