如何在 iOS 10 / Sierra / Xcode 8 中导入新的日志功能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39754199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:22:09  来源:igfitidea点击:

How do I import the new logging functions in iOS 10 / Sierra / Xcode 8?

iosxcodelogging

提问by Tom Hamming

There is a new logging systemin iOS 10 and macOS Sierra.

iOS 10 和 macOS Sierra 中有一个新的日志系统

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

但我似乎无法让它在 Xcode 中工作。os_log未被识别,文档中也未提及任何其他函数/常量。

Use of unresolved identifier 'os_log'

使用未解析的标识符“os_log”

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

我是否需要链接框架或导入标题或其他内容?我错过了一些明显的东西吗?

回答by rmaddy

In Swift:

在斯威夫特:

import os

os_log("Some message")

In Objective-C:

在 Objective-C 中:

#import <os/log.h>

os_log(OS_LOG_DEFAULT, "Some message");