简体   繁体   中英

Should debug code be removed when released (for iOS apps)

I am currently making an application using swift where I am using some debug code.

Here is my logic:

//Do some code that always gets executed
if self.debug
{
    //Do some debugging code
}
//Do more code that always gets executed

When I put this for release, should I remove the debug code or could I just set self.debug to false?

I have looked at this question: Should debugging code be left in place? , however that sounds like it's to give the user choice if they want to debug the application or not, with iOS applications users cannot debug it unless they have the Xcode project.

Preprocessor directives are a more preferable way of marking code that should only be compiled for debug builds.

#if DEBUG
// Do debug things
#endif

By using preprocessor directives, the code that you put in that block doesn't get compiled into release builds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM