Disable NSLog during iOS development to prevent it from being displayed on the console during release.

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()

define NSLog(...) {}#


define NSLog(...) NSLog(VA_ARGS)#


The above method mainly utilizes the OPTIMIZE option of the Objective-C compiler. It defines OPTIMIZE in Release mode, but not in Debug mode.

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.