Search code examples
ioscocoa-touchcocoalumberjack

CocoaLumberjack 1.9.x legacy macros enabled + DDLogWarn macros redefined


I have a project using Cocoalumberjack 2.x as Cocoapod. The project uses Obj-C mostly, but also a few Swift classes.

I allways get these warnings:

Disable legacy macros by importing CocoaLumberjack.h or DDLogMacros.h instead of DDLog.h or add `#define DD_LEGACY_MACROS 0` before importing DDLog.h.

In the main project I don't have a file that imports DDLog.h. Only CocoaLumberjack in the Pods import DDLog.h.

I also get the DDLogError macro redefined, DDLogInfo macro redefined etc warning. What's the problem leading to this?


Solution

  • I believe the issue stems from the DDLegacyMacros.h missing:

    #if DD_LEGACY_MACROS
    

    on line 21 and:

    #endif
    

    on line 75. Then in DDLog.h, replace:

    #if DD_LEGACY_MACROS
        #import "DDLegacyMacros.h"
    #endif
    

    with:

    #import "DDLegacyMacros.h"
    

    https://github.com/CocoaLumberjack/CocoaLumberjack/commit/9b31277c90d7c3968038af09a7bddd003aa28da9

    When applying the new use_frameworks! option in Cocoapods, a bridging header is automatically generated. This bridging header must import DDLegacyMacros.h directly. This leads to CocoaLumberjack 1.9.x legacy macros enabled. and macro redefined warnings.

    Therefore it is not enough to merely check the flag in DDLog.h.