Installation for iOS, macOS and tvOS.

Birch supports iOS 11+, macOS 10.13+, tvOS 11+ and Swift 5+.

Cocoapods

pod 'Birch'

Carthage

github "gruffins/birch-swift"

Swift Package Manager

.package(url: "https://github.com/gruffins/birch-swift.git", majorVersion: 1)

Inializing the logger

In your app delegate class, initialize the logger.

import Birch

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    #if DEBUG
      Birch.level = .trace // This overrides the server configuration during local development. The default is null.
      Birch.synchronous = true // This makes the logger log synchronously. The default is false.
    #else
      Birch.console = false // Disable console logging in production.
    #endif

    Birch.debug = true // This line should be removed after you've successfully integrated.
    Birch.initialize("YOUR_API_KEY", publicKey: "YOUR_PUBLIC_ENCRYPTION_KEY")

    return true
    }
}
1

If the DEBUG flag doesnt work, you may need to add -DDEBUG to OTHER_SWIFT_FLAGS.

Logging

Use the logger as you would with any logger.

Birch.t("trace message") // simplest
Birch.t { "trace message" } // most performant especially if it's expensive to build the log message.

Birch.d("debug message")
Birch.d { "debug message" }

Birch.i("info message")
Birch.i { "info message" }

Birch.w("warn message")
Birch.w { "warn message" }

Birch.e("error message")
Birch.e { "error message" }

Bindings