CocoaLumberjack: Ambiguous macro definition in mixed Obj-C and Swift project
New Issue Checklist
- I have read and understood the CONTRIBUTING guide
- I have read the Documentation or CocoaDocs
- I have searched for a similar issue in the project and found none
I’m using the CocoaLumberjack-Swift pod in a mixed Objective-C and Swift project. I had previously been using the Objective-C version and have the macros defined in my prefix.pch
Now, everything works technically, but I get all kinds of errors everywhere in my code that the DDLog macro being used is ambiguous and I’m not sure how to get rid of these errors.

The errors seem to only show up in classes where I am also importing my bridging header to access some of my Swift code: #import "MyApp-Swift.h"
So obviously the macros are also defined in the bridging header.
Is there any way around this? What is the proper way of using Cocoa Lumberjack in a mixed environment? The code still builds and runs fine but it’s annoying seeing all these “errors” everywhere.
Thanks
My prefix file includes all this:
#define LOG_ASYNC_ENABLED YES
#define LOG_LEVEL_DEF ddLogLevel
#import <CocoaLumberjack/CocoaLumberjack.h>
static const DDLogLevel ddLogLevel = DDLogLevelAll;
#ifdef DEBUG
#define DLogError(fmt, ...) DDLogError((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogWarn(fmt, ...) DDLogWarn((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogInfo(fmt, ...) DDLogInfo((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogDebug(fmt, ...) DDLogDebug((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogVerbose(fmt, ...) DDLogVerbose((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define DLogError(fmt, ...)
#define DLogWarn(fmt, ...)
#define DLogInfo(fmt, ...)
#define DLogDebug(fmt, ...)
#define DLogVerbose(fmt, ...)
#endif
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (9 by maintainers)
So you basically create a file that does the
@import CocoaLumberjack;
as well as the#define LOG_LEVEL_DEF ddLogLevel
and then you just import that file into the places where you want to use logging?@bpoplauschi Yes!
@alexpopov @tylerjames Thanks for reporting.
I have ever encountered the same problem before with old version’s CocoaLumberjack, but I haven’t recent version’s.
Could you try the latest
CocoaLumberjack
(3.4.2) and Swift 4.0? If you still encounter this problem let me know.Thanks.