Latest 1.4.0
Homepage https://github.com/SwiftyBeaver/SBObjectiveCWrapper
License MIT
Platforms ios 9.0, watchos 2.0, tvos 9.0, osx 10.11
Dependencies SwiftyBeaver
Authors

Platform iOS 8+
Platform Mac OS X 10.9+
Platform
Platform

Language Swift 2.3
Carthage compatible
Cocoapods compatible

SBObjectiveCWrapper enables you to use SwiftyBeaver logging in your Objective-C code.

Requirements

  • iOS 9.0+ / Mac OS X 10.9+
  • Xcode 8

Installation

Platform & Installation Support

iOS 9+ OSX 10.9+ watchOS 2+ tvOS 9+
Carthage
CocoaPods
Download

For installation details please see the next points.

via Carthage

You can use Carthage to install SBObjectiveCWrapper by adding this to your Cartfile:

Swift 3.0

github "SwiftyBeaver/SBObjectiveCWrapper"

Swift 2.3

github "SwiftyBeaver/SwiftyBeaver" ~> 0.7

This will also install SwiftyBeaver if it is not installed already.

via CocoaPods

To use CocoaPods just add this to your Podfile:

Swift 3.0

pod 'SBObjectiveCWrapper', '~> 1.1.0'

Swift 2.3

pod 'SBObjectiveCWrapper', '~> 0.7.0'

This will also install SwiftyBeaver if it is not installed already.

or Download

Prerequisite: Make sure you have SwiftyBeaver installed! Follow the installation directions here: SwiftyBeaver

  1. Download the latest source code.
  2. Drag & drop the /sources folder into your project (make sure "Copy items if needed" is checked)
  3. Rename the "sources" group to "SBObjectiveCWrapper" if you’d like

Usage

Let’s go!

In order to use the SwiftyBeaver Objective-C Wrapper you must get your logging environment setup using Swift.

If you already have SwiftyBeaver working with Swift you can skip ahead to the Objective-C section.

SwiftyBeaver Setup

A more detailed example of setting up SwiftyBeaver can be seen in the SwiftyBeaver readme. Below are the minimum steps you need to do in your AppDelegate.swift file to get logging working:

Near the top:

import SwiftyBeaver
let log = SwiftyBeaver.self

This makes the log variable accessible to any of your Swift files.

We then need to add a destination. This should happen as early as possible (most likely in your appDelegate:didFinishLaunchingWithOptions() method). Here we add a console destination:

let console = ConsoleDestination()  // log to Xcode Console
log.addDestination(console)

Objective-C

Once you can log from Swift now you can import SBObjectiveCWrapper into any of your Objective-C .m files:

@import SBObjectiveCWrapper;

This allows you to use the following logging macros:

SBLogVerbose(@"This is a verbose message.");
SBLogDebug(@"This is a debug message.");
SBLogInfo(@"This is an info message.");
SBLogWarning(@"This is a warning message.");
SBLogError(@"This is an error message.");

Contact & Contribute

If you have questions please contact us via the dedicated SwiftyBeaver Twitter account. Feature requests or bugs are better reported and discussed as Github Issue.

License

SBObjectiveCWrapper is released under the MIT License.

Latest podspec

{
    "name": "SBObjectiveCWrapper",
    "version": "1.4.0",
    "summary": "Objective-C wrapper and macros around SwiftyBeaver logging framework",
    "description": "SBObjectiveCWrapper brings SwiftyBeaver logging support to your Objective-C files. After setting up SwiftyBeaver in Swift, you can use a familiar C macro syntax in your Objective-C code to reuse the same logging destinations and filter settings.",
    "homepage": "https://github.com/SwiftyBeaver/SBObjectiveCWrapper",
    "license": "MIT",
    "authors": {
        "Reese McLean": "[email protected]"
    },
    "platforms": {
        "ios": "9.0",
        "watchos": "2.0",
        "tvos": "9.0",
        "osx": "10.11"
    },
    "source": {
        "git": "https://github.com/SwiftyBeaver/SBObjectiveCWrapper.git",
        "tag": "1.4.0"
    },
    "source_files": "sources",
    "dependencies": {
        "SwiftyBeaver": [
            "~> 1.4.0"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This