Backtrace Integration with iOS
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
To use CocoaPods , add the Backtrace pod to your Podfile
:
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.