ios Xcode 不会向输出控制台写入任何内容

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

Xcode doesn't write anything to output console

iosxcode

提问by ITGronk

I am working on an iPhone/iPad app. All of a sudden output console stopped displaying ANY messages AT ALL. I tried to open older project - works just fine. So I thought that local project's repository got corrupted somehow, so I tried to create a new project - no messages at all are getting written to console output. Did I do something with Xcode settings accidentally? I am at a complete loss and frustrated.

我正在开发 iPhone/iPad 应用程序。突然间,输出控制台停止显示任何消息。我试图打开旧项目 - 工作正常。所以我认为本地项目的存储库以某种方式损坏了,所以我尝试创建一个新项目 - 根本没有消息被写入控制台输出。我不小心对 Xcode 设置做了什么吗?我完全不知所措和沮丧。

Please help if you have any ideas.

如果您有任何想法,请提供帮助。

Thanks.

谢谢。

回答by Kevin

In the debug area, hit the right half-square.

在调试区,点击右半格。

debug area

调试区

N.B. area shrunk for image size. Yours should be wider.

NB 区域因图像尺寸而缩小。你的应该更宽。

回答by amergin

This question appears all over the place and is a valid one pointing to a random bug in most versions of xcode. Obviously the majority of people arriving at these answers are just unable to use xcode and therefore credit the 'show the console' type answers. I have worked on a single major project for 6 years now and this appears every month or so. I reboot devices, restart xcode, stand in the corner singing yankee doodle dandy. Nothing has occurred to me as an obvious and repeatable fix. Eventually I will start work one morning and it will be working again. Nothing I have done will be an obvious fix, no updates will have been installed. Just a heads up to those thinking they are going mad.

这个问题随处可见,是一个有效的问题,指向大多数版本的 xcode 中的随机错误。显然,获得这些答案的大多数人只是无法使用 xcode,因此归功于“显示控制台”类型的答案。我已经在一个主要项目上工作了 6 年,并且每个月左右都会出现这种情况。我重启设备,重启 xcode,站在角落唱 yankee doodle dandy。我没有想到任何明显且可重复的修复。最终我将在某一天早上开始工作,它将再次工作。我所做的一切都不会是一个明显的修复,不会安装任何更新。只是提醒那些认为他们要发疯的人。

回答by iDeveloper

Please make sure, You are selecting All Output

请确保,您正在选择所有输出

enter image description here

在此处输入图片说明

回答by Aviram Netanel

I've build a new scheme, and on the Launch option I checked: "Wait for executable to be launched" (as in the picture below)

我已经建立了一个新方案,并在启动选项上我选中了:“等待可执行文件启动”(如下图所示)

and apparently that disables the NSLog... according to this:

并且显然禁用了 NSLog ......根据这个:

NSLog not working when "wait for executable to be launched" is set

设置“等待可执行文件启动”时 NSLog 不起作用

enter image description here

在此处输入图片说明

回答by Shravya Boggarapu

Let's work this out step by step

让我们一步一步来解决这个问题

NSLog posts to stderr stream and not stdout.

NSLog 发布到 stderr 流而不是 stdout。

So, first check if you stdout also has the issue by using old school printf function (UTF8string). If this also doesn't work, the problem is most likely not with the logging function. If it does work, the problem maybe with stderr stream or the NSLog function

因此,首先使用旧式 printf 函数(UTF8string)检查您的标准输出是否也有问题。如果这也不起作用,则问题很可能与日志记录功能无关。如果确实有效,则问题可能与 stderr 流或 NSLog 函数有关

After this try logging to a file, by redirecting the stderr and then stdout also to a file. (freopen/dup2 function) If this logs properly, the problem may be in your Xcode project or console.

在此之后,尝试通过将 stderr 和 stdout 重定向到文件来记录到文件。(freopen/dup2 函数)如果此记录正确,则问题可能出在您的 Xcode 项目或控制台中。

Please note that if you are already using some sort of redirection, then logs will not be printed in the console. They will either be printed in the console or the file ONLY

请注意,如果您已经在使用某种重定向,则不会在控制台中打印日志。它们将打印在控制台或仅文件中

Try doing more similar experiments to localize your problem. Please comment on this answer with your observations to give us a better understanding of the issue

尝试做更多类似的实验来定位您的问题。请用您的观察评论此答案,以便我们更好地了解该问题

回答by Kyle Crawford

In my case it was due to hitting resource limits. iTerm was unable to fork new processes.

就我而言,这是由于达到资源限制。iTerm 无法创建新进程。

Quitting some apps or increasing resource limits may help.

退出某些应用程序或增加资源限制可能会有所帮助。

回答by Micah Montoya

XCode 9, problem still exists. I did discover that when this starts to happen I don't show the debug area (middle button in pic). Then when I re-run the app, the debug area came back up with the console showing correctly.

XCode 9,问题仍然存在。我确实发现当这种情况开始发生时,我没有显示调试区域(图片中的中间按钮)。然后,当我重新运行应用程序时,调试区域重新出现,控制台显示正确。

enter image description here

在此处输入图片说明

回答by Dave Levy

Doubtful anyone will have my same issue, but mine was because my iPad was set to Single App Mode using JAMF or MVM Deployment, and it will not log anything to the console. Other devices print to the console, but the app that is in Single App Mode will not.

怀疑任何人都会遇到我同样的问题,但我的问题是因为我的 iPad 使用 JAMF 或 MVM 部署设置为单应用模式,并且它不会将任何内容记录到控制台。其他设备打印到控制台,但处于单应用模式的应用不会。

回答by Niels Castle

Xcode 10.1 targeting iOS 11, Xcode stopped displaying console output from one build to another minutes later.

Xcode 10.1 针对 iOS 11,Xcode 停止显示从一个版本到另一分钟后的控制台输出。

I have OS_ACTIVITY_MODE as an environment variable in my scheme and I get no output in the console in Xcode.

我在我的方案中将 OS_ACTIVITY_MODE 作为环境变量,并且在 Xcode 的控制台中没有任何输出。

If I disable or remove OS_ACTIVITY_MODE from my scheme my log appears in the console - alas with a lot of system logging as well.

如果我从我的方案中禁用或删除 OS_ACTIVITY_MODE,我的日志会出现在控制台中 - 唉,还有很多系统日志记录。

Try disabling OS_ACTIVITY_MODE from Edit scheme > Run, in the section Environment Variables if you have it set there.

尝试从 Edit scheme > Run 中禁用 OS_ACTIVITY_MODE,如果您在环境变量部分设置了它。

回答by ITGronk

Not exactly sure what was happening, but everything works just fine now (after I started Xcode again today). I did have everything turned on (showing output console with "all" checked).

不确定发生了什么,但现在一切正常(在我今天再次启动 Xcode 之后)。我确实打开了所有东西(显示输出控制台并选中“全部”)。

I appreciate everybody's help.

我感谢大家的帮助。