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.
What solved it for me was changing #import <CocoaLumberjack/CocoaLumberjack.h>
to @import CocoaLumberjack;
, when using Xcode 8.0 for an Objective-C project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With