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

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -