How do I import the new logging functions in iOS 1

2020-06-01 03:47发布

问题:

There is a new logging system in iOS 10 and macOS Sierra.

But I can't seem to make it work in Xcode. os_log is not recognized, and neither is any other function / constant mentioned in the docs.

Use of unresolved identifier 'os_log'

Do I need to link a framework or import a header or something? Am I missing something obvious?

回答1:

In Swift:

import os

os_log("Some message")

In Objective-C:

#import <os/log.h>

os_log(OS_LOG_DEFAULT, "Some message");