// I need to

ModernizeUpgrade without breaking it RescueFix what someone else started Build NewTurn an idea into a product Reach More PeopleGet found, get used, include everyone

// Company

Case StudiesExpertiseAbout + CareersResourcesContact Book a call →
≡articleRescue

Smarter Debugging with Unified Logging & Activity Tracing

Debugging async code across queues and processes is hard. Apple's Unified Logging and Activity Tracing for iOS, macOS, tvOS, and watchOS can help.

Art+Logic Jul 13, 20163 min read

From the Art+Logic archive · written in 2016. The tools may have moved on; the thinking still holds.

Photo by Gabriel Manlake on Unsplash

When developing for macOS, iOS, tvOS, or watchOS to get the best performance or provide a secure solution you often need to develop apps that run asynchronously using tools such as XPC, GCD, and NSOperationQueue. Debugging this type of code can be difficult, especially when data is being passed between queues, threads, or processes.

Logging is an age old technique to help in these situations, but it’s easy to be overwhelmed by the amount of log data and to introduce or mask problems because of the observer effect, the overhead associated with many logging frameworks. I know logging isn’t exactly going to steal the headlines away from Siri integration or watchOS 3, but as a developer it’s a valuable debugging tool and the changes in these APIs look to save some significant time while debugging crashes and squashing bugs.

At WWDC this year Apple engineers gave a talk about their new Unified Logging and Activity Tracing APIs which is definitely worth checking out. The APIs are available in the latest versions of macOS, iOS, tvOS, and watchOS and are designed to replace the existing NSLog() and Apple System Logger (ASL) APIs. If you haven’t heard of the Activity Tracing APIs make sure to check out the talk given at WWDC ’14 when they were introduced. I hadn’t heard of them and based on the lack of blog posts about them, it looks like not many people did. However, the team over at objc.io unsurprisingly covered them well in their December 2014 issue on Debugging. Some of the Activity Tracing APIs introduced in 2014 are now deprecated, and are replaced by newer ones introduced this year so if you watch the talk from 2014 or read the article in objc.io, make sure to take the time to watch this year’s one as well to see what’s changed.

## Alright, so why should you use these new APIs?

New Features in Console in macOS 10.12 Sierra

ErrorsAndFaults screen capture
Easily filter logs to only show errors and faults.
Visually track activities between processes.
Visually track activities between processes. Shown here between SystemUIServer and configd.

Resources

keep going

More to explore in Rescue.

All Rescue resources →
let's talk

Got a problem like this one?

Tell us what's stuck. A real person replies within one business day.

Talk to our team →

Talk to people who know software, not a sales script.

Your first call is with Aja, our VP of Sales. He'll help make sure you're solving the right problem. Here's what you'll cover together:

  1. What you're trying to accomplish

    The business goal first, then the technology.

  2. Possible approaches

    And the tradeoffs of each, in plain language.

  3. Risks you may not have considered

    Technical and business, before they cost you.

  4. Whether AI changes the math

    What's practical, and what's just hype for your project.

  5. Sensible next steps

    Even if the right next step is not us.

book-a-call.ics

Loading the scheduler…

Open the booking page →

Some problems are easier to explain in writing. Send us a few lines about what you're working on, and we'll reply within one business day. Helpful to include:

  1. What the software does, or should do
  2. What's stuck, or what's worrying you
  3. Any deadline or budget you have in mind
note.md

Loading the form…