iProgram
iProgram

Reputation: 6557

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.

Upvotes: 0

Views: 67

Answers (1)

Aurast
Aurast

Reputation: 3688

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.

Upvotes: 2

Related Questions