novastone-media / MQTT-Client-Framework

iOS, macOS, tvOS native ObjectiveC MQTT Client Framework
Other
1.84k stars 463 forks source link

CocoaLumberjack conflict #535

Closed ameue closed 5 years ago

ameue commented 5 years ago

Short description

Before using cocoapods to introduce MQTT-Client-Framework, I introduced CocoaLumberjack with cocoapods in my project. I set static const int ddLogLevel = LOG_LEVEL in the .pch file; but I reported an error like DDLogFlag redefine confict during the compilation process.

Environment

Link to logs

Create a GIST which is a paste of your logs, and link them here. Please do NOT paste your full logs here, it will make issue very long and hard to read!

Steps to reproduce

  1. Podfile: A pod 'CocoaLumberjack' pod 'MQTTClient/MinL' pod 'MQTTClient/ManagerL' or B pod 'CocoaLumberjack' pod 'MQTTClient'
  2. pod install
  3. command+B
  4. Using A way to compile will give an error: Redeclaration of 'ddLogLevel' with a different type: 'DDLogLevel' (aka 'enum DDLogLevel') vs 'const int'
  5. Using B way to compile will give an error:DDLogFlag redefine confict

    Expected behaviour

Actual behaviour

no log

Other information

I have introduced #import <CocoaLumberjack/CocoaLumberjack.h> in the .pch file and set static const int ddLogLevel = DDLogLevelDebug;. I don't want to comment out the #import <MQTTClient / MQTTLog.h> line in the MQTTClient.h file imported by Pods.xcodeproj, I don't want to manually comment this line every time pod install. Is there any other better way to resolve this compilation conflict? If there is no good solution, I only have to manually import the mqtt source into the project, and then comment out the line that imports the log header file. This way, updating the mqtt version is not convenient with cocoapods.

jcavar commented 5 years ago

See https://github.com/novastone-media/MQTT-Client-Framework/issues/531

ameue commented 5 years ago

See #531

This does not work @jcavar

I have a suggestion, can you give the log printing permission to the application layer, remove MQTTLog.h and MQTTLog.m to reduce the dependence of MQTT-Client-Framework on the CocoaLumberjack library, as much as possible decoupling. If the application layer does not set ddLogLevel, then the log will not be printed, which is feasible.