1. 区分 Debug
和 release
模式
工程区分 Debug
和 release
在 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