objective c - Can preprocessor directives be used to import different header files for Mac and iOS? -
i writing class library mac os x , ios released cocoa framework os x , static library ios. simplify matters, intend use multiple targets in xcode. however, classes on mac os x link against cocoa.h whereas on ios link against foundation.h.
my questions are:
- could mac os x framework link against foundation.framework instead? classes used within framework nsstring, nsmutablestring, , nsmutablearray.
or use preprocessor directives within header files control framework inclusion, e.g.
#ifdef macosx #import <cocoa/cocoa.h> #else #import <foundation/foundation.h> #endif
you can use these separate platform dependent code (see targetconditionals.h
):
#ifdef target_os_iphone // ios #elif defined target_iphone_simulator // ios simulator #elif defined target_os_mac // other kinds of mac os #else // unsupported platform #endif
here's useful chart.
Comments
Post a Comment