ios - How to avoid #ifdef __x86_64__ -
i importing 3rd party library dynamic ios framework creating. however, library has following in 1 of headers:
#ifdef __x86_64__ #import <cocoa/cocoa.h> #else #import <uikit/uikit.h> #endif
this causes problems because supported platform ios, compiling devices fails error cocoa/cocoa.h file not found
.
if change generic ios device
, build, works, don't understand why.
i tried setting build active architecture only
no still gives same error.
is there can compile 64 bit iphone devices? reason library's creator thought 64 bit means should osx app.
the conditional statement in third party library makes no sense: __x86_64
specifies target cpu, not corresponding os of target.
in order conditional compile mac os vs [ios, watchos, tvos] , possibly simulator:
#if target_os_iphone || target_os_simulator #import <uikit/uikit.h> #else /* assuming mac os */ #import <cocoa/cocoa.h> #endif
these macros defined in header targetconditionals.h
each sdk. here excerpt of header:
target_os_* these conditionals specify in operating system generated code run. indention used show conditionals evolutionary subclasses. mac/win32/unix conditionals mutually exclusive. ios/tv/watch conditionals mutually exclusive. target_os_win32 - generated code run under 32-bit windows target_os_unix - generated code run under unix (not osx) target_os_mac - generated code run under mac os x variant target_os_iphone - generated code firmware, devices, or simulator target_os_ios - generated code run under ios target_os_tv - generated code run under apple tv os target_os_watch - generated code run under apple watch os target_os_simulator - generated code run under simulator target_os_embedded - generated code firmware
note, these macros defined, , either set 1
or 0
.
note target_os_mac
defined , set 1
macos, ios, watchos , tvos builds.
generally, need test whether macro equals value 1 -- testing whether defined (e.g.: #ifdef target_os_ios
) not correct.
Comments
Post a Comment