Backtrace 2.0.7

Backtrace 2.0.7

Maintained by Rick Foster, MelekR.



Backtrace 2.0.7

  • By
  • Backtrace I/O

Backtrace Integration with iOS

Supported platforms Supported languages CocoaPods compatible License: MIT Build Status

Backtrace's integration with iOS, macOS, and tvOS applications allows you to capture and report handled and unhandled exceptions so you can prioritize and debug software errors.

Installation

You can use this SDK through either Swift Package Manager or CocoaPods. The SPM package can be integrated directly within Xcode or by editing your package's Package.swift file.
Choose one of the following integration methods.

Via Xcode

  1. In File > Add Packages, search for and add https://github.com/backtrace-labs/backtrace-cocoa.git
  2. Verify your project Package Dependencies list backtrace-cocoa.
  3. Add Backtrace to your target’s Frameworks, Libraries, and Embedded Content.

Via Package.swift

Add this dependency to your Package.swift file:

.package(url: "https://github.com/backtrace-labs/backtrace-cocoa.git)

Via CocoaPods

Add the following to your Podfile:

  • Specify use_frameworks!.
  • Add the Backtrace pod:
    pod 'Backtrace'
    

Usage

Swift

let backtraceCredentials = BacktraceCredentials(endpoint: URL(string: Keys.backtraceUrl as String)!,
token: Keys.backtraceToken as String)
let backtraceDatabaseSettings = BacktraceDatabaseSettings()
backtraceDatabaseSettings.maxRecordCount = 10
let backtraceConfiguration = BacktraceClientConfiguration(credentials: backtraceCredentials,
dbSettings: backtraceDatabaseSettings,
reportsPerMin: 10,
allowsAttachingDebugger: true,
detectOOM: true)
BacktraceClient.shared = try? BacktraceClient(configuration: backtraceConfiguration)
BacktraceClient.shared?.attributes = ["foo": "bar", "testing": true]
BacktraceClient.shared?.attachments.append(fileUrl)
do {
try throwingFunc()
} catch {
BacktraceClient.shared?.send(attachmentPaths: []) { (result) in
print("AppDelegate:Result:\(result)")
}
}

Objective-C

BacktraceCredentials *credentials = [[BacktraceCredentials alloc]
initWithEndpoint: [NSURL URLWithString: Keys.backtraceUrl]
token: [Keys backtraceToken]];
BacktraceDatabaseSettings *backtraceDatabaseSettings = [[BacktraceDatabaseSettings alloc] init];
backtraceDatabaseSettings.maxRecordCount = 10;
BacktraceClientConfiguration *configuration = [[BacktraceClientConfiguration alloc]
initWithCredentials: credentials
dbSettings: backtraceDatabaseSettings
reportsPerMin: 3
allowsAttachingDebugger: TRUE
detectOOM: TRUE];
BacktraceClient.shared = [[BacktraceClient alloc] initWithConfiguration: configuration error: nil];
BacktraceClient.shared.attributes = @{@"foo": @"bar", @"testing": @YES};
BacktraceClient.shared.attachments = [NSArray arrayWithObjects:fileUrl, nil];
// sending NSException
@try {
NSArray *array = @[];
array[1]; // will throw exception
} @catch (NSException *exception) {
[[BacktraceClient shared] sendWithAttachmentPaths: [NSArray init] completion: ^(BacktraceResult * _Nonnull result) {
NSLog(@"%@", result);
}];
} @finally {
}

Documentation

For more information about the iOS SDK, including installation, usage, and configuration options, see the iOS Integration guide in the Sauce Labs documentation.