Xcode DEBUG Mode - when is it on/off?

31,682

Solution 1

enter image description here

You can also "Edit Scheme" to build Debug Configuration when archiving. See screenshot of "Edit Scheme" dialog in XCode.

Solution 2

The current version of Xcode automatically sets the DEBUG macro in new projects. It does this only for Debug build mode however.

You can edit this in your projects Build Settings.

I recommend you add a new, separate macro instead of editing the DEBUG one. Maybe you could add a DISTRIBUTION or DEPLOYMENT macro only for the release mode.

enter image description here

Share:
31,682
soleil
Author by

soleil

Updated on July 09, 2022

Comments

  • soleil
    soleil almost 2 years

    I have noticed that this works in dev mode (testing on the simulator, etc):

    #ifdef DEBUG
        //do stuff
    #endif
    

    But when I archive and distribute test builds, the app does not act in DEBUG mode even though I'm still building with the developer profile. I would like DEBUG mode to always be the case unless I build with the deployment profile and submit to Apple.

    For example, when sending test builds out, I don't want to make people buy an in-app purchase, so I do something like this:

    - (BOOL)isUpgradePurchased
    {
    #ifdef DEBUG
        return YES;
    #endif
    
    //do the real stuff to determine if purchased and return YES or NO
    }
    

    So do I also need to set a preprocessor macro DEBUG=1 for "Release"?

  • soleil
    soleil over 11 years
    But can't I also just say DEBUG=1 for Release Mode?
  • DrummerB
    DrummerB over 11 years
    You can. But that kind of defeats its purpose.
  • soleil
    soleil over 11 years
    So I should be able to just change "Release" to "Debug" in the Archive Build Configuration right?
  • msk
    msk over 11 years
    yes, but you have to change it to release before submitting to Apple.
  • soleil
    soleil over 11 years
    I have a different scheme altogether for AppStore.
  • Vivek
    Vivek over 6 years
    Hello @msk If I change only RUN mode in Build Configuration "release", then what should I change before submitting to APPLE ?