Debug your iOS native code with Mac Console

I work in React Native, and so I’m used to starting an app in the iOS simulator so that I can see my Javascript console.logs coming through into a browser console or in the terminal. However, sometimes the code your debugging is in native code.

Here’s how to see logs from native iOS code.

Bluesky
Threads
Twitter / X
Mastodon
Instagram

Make sure you’re logging something

In Native code…

    import OSLog
    let logger = Logger(subsystem: "com.yourcompany.yourapp", category: "yourCategory")

Subsystem: A reverse DNS string that identifies your app or a specific part of it.
category: A string that categorizes the log messages within your subsystem (e.g., “Networking”, “UI”, “DataPersistence”).

Example use:

logger.trace("This is a trace message.")
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.notice("This is a notice message.")
logger.warning("This is a warning message.")
logger.error("This is an error message: \(error.localizedDescription)")
logger.critical("This is a critical error, potentially leading to a crash.")

View the logs

One you’re running your app on device, you can view the logs by opening the console.

  1. Cmd+Space
  2. Type console

There are a probably a lot of other logs coming through, so use the filter settings to limit logs by subsystem or category.

That’s it!

Thanks…

I also dissect and speculate on design and development.
Digging into subtle details and implications, and exploring broad perspectives and potential paradigm shifts.
Check out my conceptual articles on Substack or find my latest below.


You can also find me on Threads, Bluesky, Mastodon, or xTwitter for more diverse posts about ongoing projects.

My latest articles

Storyboarding Immersive Experiences

Storyboarding 360 degree immersive experiences requires a different approach to traditional media…

Staging XR scenes (Keep doing your crappy little drawings)

Some people create beautiful perspective illustrations to visualise and storyboard their virtual reality designs And it’s tempting to think you’re not a strong designer if you’re not doing that too…

Focal point blocking for XR media

Planning out a linear VR experience requires thinking about where the viewers attention might be. Thinking about the focal points…

Designing immersive experiences

In traditional cinema, TV, or even the more modern phone screen, there’s limited screen real-estate. But removing that limitation creates a design problem…

The future is not prompt engineered

Let’s not pretend the importance of prompt engineering is ubiquitous. The most prevalent power of generative AI is in the way it adapts to us, not the other way around…

The typography of dates, times, & filenames

A deep dive into carefully considered date formatting, line length and general typography attributes of filenames…
Bluesky
Threads
Twitter / X
Mastodon
Instagram


Author:

Date:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.