Objective-C & Swift SDK for remote crash, exception, error reporting, and logging with
It works on all Apple *OS platforms (macOS, iOS, tvOS, watchOS, etc).
It is the preferred SDK for sending log payloads to Rollbar.
Look at Rollbar-Apple SDK as the next major reincarnation of Rollbar-iOS SDK.
It is v2 of Rollbar-iOS SDK under a new name that better describes its purpose.
Rollbar-iOS will be available for a while to allow our customers to make a move to Rollbar-Apple SDK when it most convenient to them.
All the new feature development will be happening here within Rollbar-Apple SDK.
Rollbar-Apple SDK is an open-source project available on GitHub.
Its releases are published on GitHub as well.
The SDK can also be integrated into your codebase from the following package distribution systems:
- Swift Package Manager (also known as SwiftPM or SPM)
Depending on the specific package management system, the SDK is available either as the whole (under
Rollbar-Applename) or on a per-module basis (for example,
Some package distribution systems also host packages associated with the older incarnation of this SDK, called Rollbar-iOS, that used to be published under
Rollbarpackage name and versioned at either v0.n.n or v1.n.n.
All the Rollbar-Apple SDK releases (and packages) versioned starting from v2 (since, as we already explained above, Rollbar-Apple is the v2 of Rollbar-iOS SDK renamed into Rollbar-Apple).
RollbarNotifier is the package that implements the
RollbarLogger (i.e. Notifier) - that is the thing that supports a lot of configurational options and allows to capture, package, and forward (to the preconfigured Rollbar Project on rollbar.com) exceptions, errors, log messages, telemetry, and custom data.
We offer a couple of optional crash reporting alternatives - one based on
KSCrash and another one based on
PLCrashReporter. Each package (RollbarKSCrash or RollbarPLCrashReporter) implements its own crash report collector adapter to a corresponding third-party crash reporter.
A collector is optional and can be supplied into a notifier (
RollbarLogger) initializer along with the required
RollbarAUL module implements
RollbarNotifier integration with Apple Unified Logging (AUL) and allows capture of the AUL entries as corresponding Rollbar Telemetry log events.
RollbarSwift implements components useful in cases when the SDK is used by a client code written in Swift. For example, any call chain made from Swift that eventually resolves into an Objective-C code being invoked can potentially produce an
NSException that Swift cannot handle natively. So, the module provides utility classes and components that are helping to either handle or process such scenarios.
RollbarDeploys is the package that should be used, for example by your CI Release pipeline, to track/manage your application releases/deployments so they are reported to the Rollbar Project and Rollbar would correlate the incoming payloads with specific deployment instance.
RollbarCommon is just a shared package with types used by any of the other packages as well as some potentially useful public utility classes that you may find useful.
Here are a few alternatives for installing the SDK into your software projects:
Here are a few options:
- you can download or clone the SDK source code directly from the GitHub repo;
- you can download a source code snapshot of a specific release from the repo Release page;
- you can integrate the the GitHub repo as a git submodule of your project git repository.
For example, in Xcode, by pointing your project's build target SPM settings to
https://github.com/rollbar/rollbar-apple.git repository and specifying the desired release version, or branch, or commit.
In your Cartfile, specify:
github "rollbar/rollbar-apple" ~> n.n.n
where n.n.n is the desired pod version of the SDK to use.
The SDK is configured for Cocoapods distribution on a pod-per-module basis, so you will have to separately specify each module pod dependency as needed. For example:
pod "RollbarNotifier", "~> n.n.n" pod "RollbarDeploys", "~> n.n.n"
where n.n.n is the desired pod version of the SDK to use. As the general rule, for multiple modules try using the same version.
You do not have to worry about explicitly including other internal dependencies of the modules, like RollbarCommon module pod. The SDK modules podspecs already specify these as needed.
Before using any of the types provided by the SDK modules, you need to make sure you import the modules you need. For example:
@import RollbarNotifier; @import RollbarKSCrash; // optional @import RollbarPLCrashReporter; // optional alternative to RollbarKSCrash
import RollbarNotifier import RollbarKSCrash // optional import RollbarPLCrashReporter // optional alternative to RollbarKSCrash
When setting up a notifier configuration you must at least specify your Rollbar Project's access token:
RollbarConfig *config = [RollbarConfig new]; config.destination.accessToken = @"YOUR_PROJECT_ACCESSS_TOKEN"; config.destination.environment = @"YOUR_ENVIRONMENT_ID";
let config = RollbarConfig() config.destination.accessToken = "YOUR_PROJECT_ACCESSS_TOKEN" config.destination.environment = "ENVIRONMENT"
id<RollbarCrashCollector> crashCollector = [[RollbarPLCrashCollector alloc] init]; //OR [[RollbarKSCrashCollector alloc] init]; //OR nil;
let crashCollector = RollbarPLCrashCollector() //OR let crashCollector = RollbarKSCrashCollector()
[Rollbar initWithConfiguration:config]; //OR [Rollbar initWithConfiguration:config crashCollector:crashCollector];
Rollbar.initWithConfiguration(config) //OR Rollbar.initWithConfiguration(config, crashCollector: crashCollector)
[Rollbar infoMessage:@"See this message on your Rollbar Project Dashboard..."];
Rollbar.infoMessage("See this message on your Rollbar Project Dashboard...")
There are other dedicated method overloads for logging
NSErrorrs with different levels of log severity.
Updated 2 days ago