inheritance - Inheriting a class from static library causing undefined symbols in objective c -
i have static library in work space. in there apple.h & .m file in .h file defined 2 @interface apple : nsobject & @interface greenapple : nsobject
in same work space have ios application project references static library. in application when inherit greenapple 'undefined symbols' error both device , simulator build. but, there no error if inherit apple.
across project should imported .h , inherited class has same or greenapple inheritance should work though under apple.h file?
edit
to test theory renamed file match error class, still same error. actual implementation given below file cmsgmealmenuitem.h.
@interface cmsgmealmenu : nsobject @property (nonatomic, readonly) cmsgmealtype mealtype; @property (nonatomic, readonly) nsdate *orderstarttime; @property (nonatomic, readonly) nsdate *orderendtime; @property (nonatomic, readonly) nsarray *items; @end @interface cmsgmealmenuitem : nsobject @property (nonatomic, readonly) nsstring *itemid; @property (nonatomic, readonly) nsstring *itemdescription; @property (nonatomic, readonly) nsstring *itemsummary; @property (nonatomic, readonly) nsnumber *itemprice; @end
always cmsgmealmenuitem inheritance throws undefined symbol error, whether .h file name matches not. but, couldn't spot how different cmsgmealmenu definition? doesn't throw error if inherit it.
edit
referring cmsgmealmenuitem method parameter doesn't shows build error, errors if inherit.
this works
@interface msmealmenuitem : cmsgmealmenu @property (nonatomic, retain) nsnumber *quantity; @property (nonatomic, assign) bool isaddedtocart; + (msmealmenuitem *) createmsmealmenuitemfromcmsgmealmenuitem:(cmsgmealmenuitem *)cmsgmealmenuitem; @end
if change parent cmsgmealmenuitem throws undefined symbol error below either build device or simulator.
undefined symbols architecture i386: "_objc_class_$_cmsgmealmenuitem", referenced from: _objc_class_$_msmealmenuitem in msmealmenuitem.o "_objc_metaclass_$_cmsgmealmenuitem", referenced from: _objc_metaclass_$_msmealmenuitem in msmealmenuitem.o ld: symbol(s) not found architecture i386 clang: error: linker command failed exit code 1 (use -v see invocation)
you need link app static library contains cmsgmealmenuitem
.
see: http://www.xs-labs.com/en/archives/articles/xcode-static-libraries/
Comments
Post a Comment