开发者

Xcode project complains about missing files if a linked framework contains private headers

开发者 https://www.devze.com 2022-12-28 14:00 出处:网络
开发者_StackOverflow社区My problem is this: My framework contains public and private headers - the public headers import private headers in the framework

开发者_StackOverflow社区My problem is this:

  • My framework contains public and private headers - the public headers import private headers in the framework
  • My app that links against this framework imports public headers

Now when I compile it, Xcode complains about missing files (the private headers that are indirectly imported via the frameworks public headers). I read somewhere on stackoverflow that I should do this:

"In the public header file use @class to include other interfaces and use #import in the implementation file (.m)."

I find this solution pretty unsatisfying - you have to use it for circular dependencies, too. Is there any better way to keep my headers private?


To get about circular references use the @class directive in the header and the #import in the source file.

In OtherClass.h:

@class MyClass;
@interface OtherClass
{
    MyClass *myInstance;
}
@end

In OtherClass.m:

#import "OtherClass.h"
#import "MyClass.h"
@implement OtherClass
@end

In MyClass.h:

@class OtherClass;
@interface MyClass
{
    OtherClass *otherInstance;
}
@end

In MyClass.m:

#import "MyClass.h"
#import "OtherClass.h"
@implement MyClass
@end
0

精彩评论

暂无评论...
验证码 换一张
取 消