Search

Own Your Crash Logs with PLCrashReporter: Part 3

Alan Scarpa

Jared Sinclair

2 min read

Jan 12, 2021

iOS

Own Your Crash Logs with PLCrashReporter: Part 3

In the third post of our PLCrashReporter series, we will walk through how to get PLCrashReporter up and running on your machine. And make sure to check out Part 1 and Part 2 of our series if you haven’t already.

Walkthrough

It’s time to install PLCrashReporter and get your first crash report!

Step 1: Download the Library

First, you need to download the latest release of PLCrashReporter to your computer. As of this writing, 1.5.1 is the latest release. Visit the PLCrashReporter releases page and download PLCrashReporter-1.5.1.zip.

You may have noticed another zip file with the word “Static” included in its filename. This is the static library version of PLCrashReporter which we won’t use for this walkthrough. We’ll use the dynamic framework. To learn more about dynamic frameworks versus static libraries check out this BNR blog post on libraries vs frameworks.

Step 2: Set Up the Project

Now that you have the library downloaded, it’s time to put it in an Xcode project.

Open Xcode 12 and create a new iOS app project for this walkthrough. Make sure to use the Swift language with Swift UI for your app interface, but select to use a UIKit App Delegate for its lifecycle. Name your app “PLCExample.”

Unzip PLCrashReporter-1.5.1.zip and go into the “iOS Framework” folder where you’ll see an item named CrashReporter.framework. Copy and paste it into your project’s directory.

Finally, drag the newly-pasted framework from your project’s directory into your Xcode project. It should look like this:

framework on pl crash reporterNow PLCrashReporter is in your project!

Step 3: Add a Bridging Header

Because PLCrashReporter is an Objective-C library, you’ll need to set up a bridging header before you can start playing with it in your Swift project.

The easiest way to create a bridging header is to create a new Objective-C class in Xcode. Xcode will offer to set up the bridging header for you so you just need to accept its offer, then delete the Objective-C class files while keeping the bridging header.

Once you have your bridging header, open it up and add #import <CrashReporter/CrashReporter.h> This exposes PLCrashReporter to your Swift project.

Step 4: Enable the Crash Reporter

It’s time to start writing some code. To kick things off, you need to enable PLCrashReporter. Open up your AppDelegate and put the following in didFinishLaunchingWithOptions:

let reporter = PLCrashReporter()
reporter.enable()

That’s it! You’ve got PLCrashReporter up and running, ready to record crashes. Time to buckle up and crash your app. We will cover this in our next post!

Alan Scarpa

Author Big Nerd Ranch

Alan is a Managing Senior Mobile Developer at BNR. When he’s not coding, you can find him on cross-country road trips with his wife, making music, or tossing the frisbee to his German Shepherd.

Jared Sinclair

Author Big Nerd Ranch

Jared Sinclair is a Managing Architect at Big Nerd Ranch, and an iOS app developer and designer. He lives in Oklahoma with his wife and two sons.

Speak with a nerd

Schedule a call today! Our team of nerds are ready to help

Let's Talk

Related Posts

What is GraphQL?

GraphQL

GraphQL can revolutionize your product by improving performance, reducing friction between development teams, and even helping with documentation. But it's important to understand the...

Read More

We are ready to discuss your needs.

Stay in Touch WITH Big Nerd Ranch News