Xcode 9,我的 NSLog() 去哪里了?未显示在 Xcode 控制台或 Console.app 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47004127/
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 10:23:31  来源:igfitidea点击:

Xcode 9, where are my NSLog()s going? Not showing in Xcode console or Console.app

iosxcodenslog

提问by Kenny Wyland

I'm trying to do some basic logging while I work on an app. I tossed some NSLog()s into my code, but nothing is being printed to the Xcode console below. Literally nothing, not even some startup info as the app launches, etc.

我正在尝试在开发应用程序时进行一些基本的日志记录。我NSLog()在我的代码中加入了一些s,但下面的 Xcode 控制台没有打印任何内容。几乎没有,甚至没有应用程序启动时的一些启动信息等。

I've got my Xcode console set to display All Outputand I've got the variable inspector and the Console open:

我已将 Xcode 控制台设置为显示,All Output并且已打开变量检查器和控制台:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

I heard about Logging changes and that a new Console.app was introduced that would let me view the logs on the simulators as well, so I thought maybe the logs would show up over there, but while I do so lots of system messages happening I don't see the NSLog()s that I'm making.

我听说 Logging 更改并且引入了一个新的 Console.app,它可以让我在模拟器上查看日志,所以我想也许日志会显示在那里,但是当我这样做时,发生了很多系统消息,我看不到我正在制作的 NSLog()。

Am I missing something? Is there a new setting I need to flip? Where can I see my NSLog()s?

我错过了什么吗?是否有我需要翻转的新设置?我在哪里可以看到我的 NSLog()s?

EDIT:

编辑:

I was doing this with an iOS 11 simulator and got no console output. When I switched to an iOS 9 simulator then I got all of the console output.

我使用 iOS 11 模拟器执行此操作,但没有控制台输出。当我切换到 iOS 9 模拟器时,我得到了所有的控制台输出。

回答by Kenny Wyland

Figured it out. It's not an intermittent issue or one that can just be fixed with a restart. It's a Run configuration issue.

弄清楚了。这不是间歇性问题,也不是可以通过重新启动来解决的问题。这是一个运行配置问题。

Click on the Run Scheme selector in the top left of Xcode's toolar.

单击 Xcode 工具栏左上角的 Run Scheme 选择器。

Click Manage Schemes.

单击管理方案。

enter image description here

在此处输入图片说明

Click on your main App Project.

单击您的主应用程序项目。

Click the Edit button in the bottom left.

点击左下角的编辑按钮。

enter image description here

在此处输入图片说明

Uncheck OS_ACTIVITY_MODE.

取消选中OS_ACTIVITY_MODE

Click Close.

单击关闭。

Viola. All your console logs come back.

中提琴。您所有的控制台日志都会回来。

enter image description here

在此处输入图片说明