开发过程中使用的 NSLog 、assert 和NSAssert 之类的东西在release版本里如何去掉?
NSLog没有预处理宏来控制开启关闭,可以在工程的pch文件里自己控制。
#ifdef DEBUG
# define LOG(...) NSLog(__VA_ARGS__)
# define LOG_CURRENT_METHOD NSLog(NSStringFromSelector(_cmd))
#else
# define LOG(...) ;
# define LOG_CURRENT_METHOD ;
#endif
然后在Bulid Settings里的Apple LLVM compiler 3.* - Preprocessing 里的Debug里添加DEBUG=1。在Release里添加NDEBUG去掉assert,NS_BLOCK_ASSERTIONS 去掉NSAssert。