SBObjectiveCWrapper enables you to use SwiftyBeaver logging in your Objective-C code.
- iOS 9.0 / Mac OS X 10.9
- Xcode 9
\ | iOS 9 | OSX 10.9 | watchOS 2 | tvOS 9 |
---|---|---|---|---|
Carthage | ✅ | ✅ | ✅ | ✅ |
CocoaPods | ✅ | ✅ | ✅ | ✅ |
Download | ✅ | ✅ | ✅ | ✅ |
For installation details please see the next points.
You can use Carthage to install SBObjectiveCWrapper by adding this to your Cartfile:
github "SwiftyBeaver/SBObjectiveCWrapper"
github "SwiftyBeaver/SwiftyBeaver" ~> 0.7
This will also install SwiftyBeaver if it is not installed already.
To use CocoaPods just add this to your Podfile:
pod 'SBObjectiveCWrapper', '~> 1.1.0'
pod 'SBObjectiveCWrapper', '~> 0.7.0'
This will also install SwiftyBeaver if it is not installed already.
Prerequisite: Make sure you have SwiftyBeaver installed! Follow the installation directions here: SwiftyBeaver
- Download the latest source code.
- Drag & drop the
/sources
folder into your project (make sure "Copy items if needed" is checked) - Rename the "sources" group to "SBObjectiveCWrapper" if you'd like
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)
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.");
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.
SBObjectiveCWrapper is released under the MIT License.