Skip to content

backtrace-labs/backtrace-crashpad-cocoapod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Backtrace-Crashpad

Backtrace's binary package for Crashpad with modifications provided by Backtrace.

Crashpad

Crashpad is a crash-reporting system.

Documentation

Source Code

Crashpad’s source code is hosted in a Git repository at https://chromium.googlesource.com/crashpad/crashpad.

Other Links

Installation

via CocoaPods

To use CocoaPods just add this to your Podfile:

pod 'Backtrace-Crashpad'

Note: It is required to specify use_frameworks! in your Podfile.

Sample usage

#include <iostream>
#include <base/files/file_path.h>
#include <client/crash_report_database.h>
#include <client/settings.h>
#include <client/crashpad_client.h>

void startCrashpad() {

std::map<std::string, std::string> annotations;
annotations["format"] = "minidump";
annotations["token"] = "<BACKTRACE_TOKEN>";
std::vector<std::string> arguments;
CrashpadClient client;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
std::unique_ptr<CrashReportDatabase> database = CrashReportDatabase::Initialize(base::FilePath{[[docsPath stringByAppendingString:@"/crashpad_db"] cStringUsingEncoding: NSUTF8StringEncoding]});
database->GetSettings()->SetUploadsEnabled(true);
NSString *crashpadHandlerPath = [[NSBundle mainBundle] pathForResource: @"crashpad_handler" ofType: @""];
arguments.push_back("--no-rate-limit");
client.StartHandler(base::FilePath{[crashpadHandlerPath cStringUsingEncoding: NSUTF8StringEncoding]},
                    base::FilePath{[[docsPath stringByAppendingString:@"/crashpad_db"] cStringUsingEncoding: NSUTF8StringEncoding]},
                    base::FilePath{[[docsPath stringByAppendingString:@"/crashpad_db"] cStringUsingEncoding: NSUTF8StringEncoding]},
                    "https://team.sp.backtrace.io:6098/post",
                    annotations,
                    arguments,
                    true,
                    true);

// Crash the app
DoTheImpossible();
}

Known limitations

This package currently does not support distributing macOS app through the Mac App Store, because App Sandbox capability needs to be disabled.