0

I am working on an Objective C framework and we want to hide some debug related methods in our release version. I thought using #ifdef DEBUG can easily server for that purpose, so put the debug related method in a #ifdef block:

#ifdef DEBUG
+(void)unregisterDevice OBJC_VISIBLE;
#endif

The above code block shows up exactly, in the aggregated framework when I build it with either of our Debug, or Release targets! I thought, the compiler would remove #ifdef and #endif when DEBUG is defined and will hide the whole block when DEBUG is not defined. Would you please help me resolve this issue?

Hooman Malek
  • 499
  • 3
  • 11
  • Show how you're setting your Debug and Release compiler flags. – Gereon May 13 '20 at 16:51
  • Target > Build Settings > Apple Clang Preprocessor > Preprocessor Macros > Configuration > DEBUG=1 (for our Debug configuration). The Release configuration doesn't have the DEBUG macro. – Hooman Malek May 13 '20 at 17:08
  • What do you mean "shows up exactly, in the aggregated framework when I build it"? Are you looking at a header file that got copied into the framework headers? Nothing will actually modify the headers as they're copied. They will always be copied verbatim. – Ken Thomases May 13 '20 at 18:02
  • I meant you would see the exact block of code including #ifdef Debug there. Is there any way to hide that method declaration in the header file? – Hooman Malek May 13 '20 at 18:09
  • No, preprocessor directives don't modify header files, they only modify what input the compiler sees to generate the binary. – Gereon May 13 '20 at 20:47

0 Answers0