I'm trying to configure cocoalumberjack and when I've added ddLogLevel
set to LOG_LEVEL_VERBOSE
XCode throws "use of undeclared identifier" error. Why is that? How to avoid?
This question indicates that clearing DerivedData
and restarting Xcode solves this kind of error.
However you should not include variables in the pre-compiled header as it will be included in every source file and prefix files are somewhat complicated compared to normal header files.
Better is to have use a Constants.h
file which contains:
extern int ddLogLevel;
and #import
that into your prefix file.
Then create an Constants.m
with:
int ddLogLevel =
#ifdef DEBUG
LOG_LEVEL_VERBOSE;
#else
LOG_LEVEL_ERROR;
#endif
This way there is only one instance of ddLogLevel
and it can be easily changed at runtime if necessary.
See this question for hints about prefix file best practices.