zoukankan      html  css  js  c++  java
  • Remove Debug Code For Release Build

    From: http://mobiledevelopertips.com/debugging/remove-debug-code-for-release-build.html

    When it’s time to remove debug code and log messasges from your application, it’s straight forward if you follow a few simple steps during development.

    First, wrap debugging code in a block similar to the following:

    #ifdef DEBUG
      // Debug code here...  
    #endif

    From the Edit Scheme dialog select the Run tab. In the Info tab, set the Build Configuration to Debug. By the way, when you create a new project, Debug is the default value, so you can skip this step if you have not previously changed the value.

    When you are ready to have the debug code removed from your build, return to the Edit Scheme menu and set the Build Configuration to Release. When you rebuild the project, the code inside the #ifdef DEBUG – #endif will no longer be included in the app.

    You can see the preprocessing macro definitions that make this possible by opening the Build Settings and searching for debug. You will find the DEBUG macro defined as follows:

    Removing Console / NSLog Messages

    In a previous post, Debugging Macros, I wrote an alternative for NSLog. Along with this, I included code to turn those same messages off. However, there is now a much cleaner way to do this using the DEBUG preprocessor macro shown above:

    #ifdef DEBUG
      #define debug(format, ...) CFShow([NSString stringWithFormat:format, ## __VA_ARGS__]);
    #else
      #define debug(format, ...) 
    #endif

    You can now write debugging messages to the console as follows, which will be removed when creating a release build:

    debug(@"Your debug message here...");
     
  • 相关阅读:
    HR问“你目前有几个offer”,聪明人会怎么说?
    秋招还有 1 个月到达战场,请做好准备 !
    我人生中的第一场Java面试
    MZ头里面的东西。真他妈多
    特殊的一卦
    今天出门去办事,又倒霉了
    内核回调
    sys_call_table HOOK
    起一卦,看看情况
    我的简陋界面库的模块组成
  • 原文地址:https://www.cnblogs.com/simonshi2012/p/2681915.html
Copyright © 2011-2022 走看看