TargetConditionals 是在user/include 一个关于运行目标情况的一个宏定义,能让你知道运行机型、cup类型等等。
#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) )
#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#define TARGET_OS_OSX 0
#define TARGET_OS_IPHONE 1
#define TARGET_OS_IOS 1
#define TARGET_OS_WATCH 0
#define TARGET_OS_BRIDGE 0
#define TARGET_OS_TV 0
#define TARGET_OS_SIMULATOR 1
#define TARGET_OS_EMBEDDED 0
#define TARGET_IPHONE_SIMULATOR TARGET_OS_SIMULATOR /* deprecated */
#define TARGET_OS_NANO TARGET_OS_WATCH /* deprecated */
#if defined(__ppc__)
#define TARGET_CPU_PPC 1
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_LITTLE_ENDIAN 0
#define TARGET_RT_BIG_ENDIAN 1
#define TARGET_RT_64_BIT 0
#ifdef __MACOS_CLASSIC__
#define TARGET_RT_MAC_CFM 1
#define TARGET_RT_MAC_MACHO 0
#else
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#endif
#elif defined(__ppc64__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 1
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_LITTLE_ENDIAN 0
#define TARGET_RT_BIG_ENDIAN 1
#define TARGET_RT_64_BIT 1
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#elif defined(__i386__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 1
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 0
#elif defined(__x86_64__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 1
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 1
#elif defined(__arm__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 1
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 0
#elif defined(__arm64__)
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 0
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 1
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 1
#else
#error unrecognized GNU C compiler
#endif
在文件里我们可以这样写判断运行机型
#if !TARGET_OS_WATCH
#import "AFNetworkReachabilityManager.h"
#endif
#if !TARGET_OS_WATCH
#import "test1"
#endif
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
#import
#else
#import
#endif