eklektek
eklektek

Reputation: 1173

Obj-c exporting .h files for a Static Library - don't want to expose class definition

I am struggling to create an iOS static library correctly/cleanly.

So far I have used Extension a to create a separation between my internal (private) .h declarations and the public .h declaration (that gets exported).

I have "successfully" created the library and seen it working. However I am still exposing the class declaration in the public WTDevice.h

@interface WTDevice : NSObject <WTMinorStateDelegate,CBPeripheralDelegate>

As WTDevice inherits from WTMinorStateDelegate I have to export protocol WTMinorStateDelegate too, which I don't wish todo as this is only used within the library.

BTW the WTDevice extension is in WTDevice_internal.h which doesn't get exported.

I am sure there is a way of putting the line:

@interface WTDevice : NSObject <WTMinorStateDelegate,CBPeripheralDelegate>

into WTDevice.m (making it private), however I have failed so far. The question is what replaces it when I remove it from the WTDevice.h file?

Thanks

Upvotes: 2

Views: 143

Answers (1)

Brian Walker
Brian Walker

Reputation: 8908

In WTDevice.m add this before the @implementation block to create a private category.

@interface WTDevice () <WTMinorStateDelegate>
@end

In WTDevice.h remove WTMinorStateDelegate from the @interface line.

Upvotes: 2

Related Questions