iOS工程宏定义使用

1. 区分 Debugrelease 模式

工程区分 Debugrelease

Build Settings -> Preprocessor Macros -> Debug-DEBUG=1 (这里的DEBUG一定和判断对应)"

 `#ifdef DEBUG`不使用, `#if DEBUG`
#ifdef DEBUG
#define NSLog(...)  NSLog(__VA_ARGS__)
#define MyLog(...)  NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#define MyLog(...)
#endif

2. 区分真机和模拟器

TARGET_OS_IPHONE -- 此判断不会有效果.

请使用 #if 判断不要使用 #ifdef 判断不准确.

#if TARGET_IPHONE_SIMULATOR
    // simulator
#elif
    // device
#endif
持续更新中

你可能感兴趣的:(iOS工程宏定义使用)