Our QA guy informed me one day that he doesn’t see our log messages when testing on an iOS 10 device.
“Good morning Siri darling, ” I clicked the round icon on the top right edge of my screen. “I don’t see my NSLog messages, please advise…”
“You should switch to os_log API”, she arrogantly replied. “And please stop asking me how much is 36 times purple, which bear is best or can Chuck Norris beat Thor in a fistfight”.
Thank you Siri, I’ll see what I can do.
Basically, a quick look around our code revealed that our NSLog calls are no longer displayed in the console application. Now, we write our code as a library. This means that our log messages within the app, the ones our QA looks for when testing, were part of a dylib compiled in release. And under those circumstances, NSLog doesn’t work starting with iOS 10.0. What does work? Well, according to Siri, a new API, the os_log API, should do the trick.
What is os_log API, you ask? Well, officially it’s called the “Unified Logging System.” Its function is described as “centralizing the storage of log data in memory and in a data store on disk.”
And so we were faced with quite the conundrum. The new os_log API is the way to go, Siri said so herself, but it’s only available starting with iOS 10.0. We had no choice – we had to use the new API when available, but still use NSLog for the old versions.
How were we to do that?