In iOS development, the most commonly used method to record logs is by using the NSLog() function. By default, NSLog() will output logs to the console during debugging. However, when the app is released, we don't need to display the logs anymore. In this case, the strategy is to either not display the logs or write them to a log file.
You can directly disable NSLog and prevent it from displaying on the console using the following method.
//
// Close all NSLog()
//
#ifdef OPTIMIZE
define NSLog(...) {}#
#else
define NSLog(...) NSLog(VA_ARGS)#
#endif
The above method mainly utilizes the OPTIMIZE option of the Objective-C compiler. It defines OPTIMIZE in Release mode, but not in Debug mode.