Ios XCode:使用define检查目标平台

Ios XCode:使用define检查目标平台,ios,objective-c,xcode,macos,Ios,Objective C,Xcode,Macos,是否存在一些指定目标平台的标准定义,例如DEST_IOS或DEST_OSX?或者我必须将其添加到项目的设置中 在Mac和iPad上使用相同的库时,我需要这个。是的。包括TargetConditionals.h,我使用以下方法使它们更易于使用: #import <TargetConditionals.h> #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR #define TARGET_OSX 1 #else #defi

是否存在一些指定目标平台的标准定义,例如
DEST_IOS
DEST_OSX
?或者我必须将其添加到项目的设置中


在Mac和iPad上使用相同的库时,我需要这个。

是的。包括
TargetConditionals.h
,我使用以下方法使它们更易于使用:

#import <TargetConditionals.h>

#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
#define TARGET_OSX 1
#else
#define TARGET_IOS 1
#endif
#if TARGET_OSX
    // OSX-specific thing here
#else
    // iOS-specific thing here
#endif