Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode DEBUG Mode - when is it on/off?

Tags:

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"?

like image 540
soleil Avatar asked Sep 19 '12 16:09

soleil


People also ask

How do I enable debug mode in Xcode?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

How do I release mode in Xcode?

To create a release build, you have to edit your current scheme (⌘<) and highlight "Run [name of application]. On the right, select "Build Configuration" and choose "Release". Build as usual.

How do you stop a breakpoint in Xcode?

Specify Where to Pause Your App Xcode displays a breakpoint icon to indicate the location. Drag a breakpoint up or down to move it to another location; drag it away from the gutter to remove it. Click the breakpoint icon in the debug area toolbar to activate or deactivate all breakpoints.


2 Answers

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

like image 122
DrummerB Avatar answered Oct 21 '22 14:10

DrummerB


enter image description here

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

like image 25
msk Avatar answered Oct 21 '22 16:10

msk