Some quick scribbles that will hopefully save somebody else from a lot of rebooting and cursing.

Hardware: MacMini M1

OS: Big Sur 11.3

os_log has been the “default” logging system on macOS since 10.12 (AKA Sierra). Almost all of the system routines go through os_log except when they don’t ( I’m looking at you NSLog).

Because I’m masochistic, I’m doing some work on a KEXT that we need on ARM64. It had a pile of #ifdef and some other weird and wonderful logging code that I decided should be moved over to os_log. Sadly this led to a rathole. …

Notes on how I was able to debug my kernel extension on a 2020 M1 Mini.

As of Mar 2021, kernel debugging on Apple Silicon is rather primitive compared to Intel. All you can do right now is inspect the current state of the kernel when it has halted due to a panic or non maskable interrupt (NMI). You can’t set breakpoints, step into code or continue post NMI.


You need two Macs.

The target device is the Mac that runs the code you want to debug.

The host device is the Mac that runs the debugger.

Download the appropriate…

We build a lot of code for Apple platforms at Google, and spend a fair amount of time trying to optimize our builds. We have noticed that Macs are quite sensitive to thermals, and have done some work attempting to track the thermal characteristics of our machines and how that affects their build speeds. Here’s some info that we discovered that may be useful in your own explorations. The intended audience for this is someone quite familiar with macOS programming.


Apple has a plethora of APIs to monitor thermals on their platforms. Warning, your mileage may vary… Note also that…

This may be ~30 years too late, but as they say the best time to start was 30 years ago, the second best time to start is right now.

I still write a lot of code in Objective C. I know all the pundits tell me that I should be writing in Swift, but I have a lot of Objective C code that I maintain, and I’m more familiar with Objective C (and more importantly all of the tooling underneath it). If you’d like to debate Swift vs ObjC please go somewhere else. …

Block syntax was introduced by Apple to clang in 2008 and has slowly been sprinkled throughout the operating system frameworks ever since. It pre-dated lambdas in C++ (which appeared in C++11) and is compatible with C, Objective C and Objective C++.

A lot of documentation has been written about using Blocks in Objective C, such as the infamous gosh-darn-block-syntax site, and the perils of retain loops in blocks. …

Objective C is a dynamically typed programming language that allows full runtime introspection as well as runtime modification. This means that you can examine, modify, and create classes, methods, instance variables (ivars), properties etc. while your program is running.

For example, the following code snippet creates a new Objective C class at runtime called “MyClass” which overrides the -description method to return @"Hello" .

Creating an Objective C class at runtime

<objc/runtime.h> contains all the functions needed to add ivars, class methods, properties and more should you want to create a more fully featured class.

Note that as far as…

As has been widely reported, the President Elect of the United States made a spelling mistake in a tweet that he posted this morning. The fact that he made a spelling error is not in my opinion big news. I am probably going to make several errors as I type out this post, and I am doing it on a real keyboard as opposed to on a mobile device (the general assumption based on internet sleuthing is that Mr. Trump posts from an Android device). My major concern however is that the spelling mistake actually made it out to the…

Dave MacLachlan

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store