Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I'm going to create a source code file that is meant to be used only in a development environment. Is there a way to tell Xcode to compile the file only for debug builds?
 
Add a define to just the Debug build:
Code:
-DMOONMAN_DEBUG=1

Put this in your source file:
Code:
#if MOONMAN_DEBUG

...entire current source of file goes here...

#endif


Another alternative is two separate targets. One has the source file in the target, the other doesn't.
 
  • Like
Reactions: Madd the Sane
There's already a DEBUG in there that activates via a scheme in Xcode, right?
 
What exactly are you trying to accomplish here? Having a different code path for testing usually means you aren't actually testing what is going to be used. I would suggest using proper mocks/stubs for testing (with separate build targets and injections), or passing a debug log level or similar if you want more info.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.