1

我有一个使用 Cocoalumberjack 2.x 作为 Cocoapod 的项目。该项目主要使用 Obj-C,但也使用一些 Swift 类。

我总是收到这些警告:

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.

在主项目中,我没有导入 DDLog.h 的文件。只有 Pod 中的 CocoaLumberjack 会导入 DDLog.h。

我也收到DDLogError macro redefinedDDLogInfo macro redefined警告。导致这种情况的问题是什么?

4

1 回答 1

5

我相信问题源于 DDLegacyMacros.h 缺失:

#if DD_LEGACY_MACROS

在第 21 行和:

#endif

在第 75 行。然后在 DDLog.h 中,替换:

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

和:

#import "DDLegacyMacros.h"

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

在 Cocoapods 中应用新use_frameworks!选项时,会自动生成一个桥接头。此桥接头必须DDLegacyMacros.h 直接导入。CocoaLumberjack 1.9.x legacy macros enabled.这会导致macro redefined警告。

因此,仅检查 DDLog.h 中的标志是不够的。

于 2015-08-04T22:45:52.847 回答