How do I mark a source file as for debug builds only?

Discussion in 'Mac Programming' started by moonman239, Mar 25, 2016.

  1. moonman239 macrumors 68000

    Mar 27, 2009
    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?
  2. chown33 macrumors 604

    Aug 9, 2009
    Add a define to just the Debug build:
    Put this in your source file:
    ...entire current source of file goes here...

    Another alternative is two separate targets. One has the source file in the target, the other doesn't.
  3. robvas macrumors 68030

    Mar 29, 2009
    There's already a DEBUG in there that activates via a scheme in Xcode, right?
  4. Mernak macrumors 6502

    Apr 9, 2006
    Kirkland, WA
    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.

Share This Page