0

I'm currently writing some swift libraries to be included in an App that uses CocoaLumberjack to log. So initially I've added CocoaLumberjack as a dependency to all of them and it works quite well.

Then I've seen this ticket where they say, that you should not add it as a dependency, but use if it is there.

Despite that I've already seen some projects on GitHub where they do exactly that in Objective-C, I haven't seen it yet in Swift.

Can somebody point me to a sample project or help me to find the right direction to take

THX

oguz ismail
  • 1
  • 16
  • 47
  • 69
Hons
  • 3,804
  • 3
  • 32
  • 50

1 Answers1

0

Your should add CocoaLumberjack/Swift as a dependency if your library uses it as a logger.

But your library code should not add any loggers (DDTTYLogger, DDFileLogger, etc.) to avoid log duplication.

Adding loggers should be done in final application that uses your library.

For library itself it could be test bundle with tests:

class YourKitTests: XCTestCase {
    override func setUp() {
        super.setUp()
        DDLog.add(DDTTYLogger.sharedInstance(), with: .verbose)
    }
}
Max Potapov
  • 1,267
  • 11
  • 17
  • If you "Adding loggers should be done in final application that uses your library.", then why don't you add CocoaLumberjack/Swift as a dependency in the final application only? – allenlinli Aug 22 '20 at 23:20