nslog 停止在 xcode 中工作

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

nslog stopped working in xcode

iphonexcodenslog

提问by Jules

I have a strange issue and possibly a bug. My NSLog statements have stopped working completely, they do not print even in view did load, application didfinishlaunching etc. The have all turned a brown colour (the same colour as a pragma mark in xcode) and they all have a warning saying 'expression result unused'. Has anyone ever seen this before or know what to do? Am i running in some kind of weird mode? Im running xcode 4.0.2.

我有一个奇怪的问题,可能是一个错误。我的 NSLog 语句已完全停止工作,即使在视图加载、应用程序 didfinishlaunching 等中也不会打印。它们都变成了棕色(与 xcode 中的编译指示标记颜色相同),并且它们都有一个警告说“表达结果”没用过'。有没有人以前见过这个或知道该怎么做?我是否以某种奇怪的模式运行?我正在运行 xcode 4.0.2。

Many thanks

非常感谢

Jules

朱尔斯

回答by xfze

for completeness, I had the same problem and the answer was different, hope it helps someone else who bumps into this post:

为了完整起见,我遇到了同样的问题并且答案不同,希望它可以帮助碰到这篇文章的其他人:

I had a framework (an Amazon one) redefining NSLog, went there (Cmd+Click on the Brown NSLog) and commented out the redefinition...

我有一个重新定义 NSLog 的框架(一个亚马逊的),去了那里(Cmd+单击 Brown NSLog)并注释掉重新定义......

回答by Jules

The actual problem was the release_build set to 1. So it wasn't recognizing nslog, as you said it was set for a release build.

实际问题是将 release_build 设置为 1。所以它无法识别 nslog,正如您所说,它是为发布版本设置的。

回答by Radix

I had the same issue :

我遇到过同样的问题 :

what worked for me is given below:

下面给出了对我有用的方法:

  • Remove the derived data folder
  • After removing derived data perform the clean action (You can see this option in the product menu)

  • Quit the Xcode and start it again.

  • 删除派生数据文件夹
  • 删除派生数据后执行清理操作(您可以在产品菜单中看到此选项)

  • 退出 Xcode 并重新启动它。

And this did the trick all my NSLog were working fine.

这使我所有的 NSLog 工作正常。

Hoep this helps

希望这有帮助

回答by user1046037

  1. Ensure that scheme chosen corresponds to Debug mode because sometimes the pch file might have some definitions such that logging is done only in the debug mode (Scheme is on to the left of the place where you select iPhone Simulator / iOS Device)

  2. In the view select Debug Area (There are 3 view buttons, on the top right hand corner of Xcode, press the center button)

  3. Select "Show variables view and the console" (In the debug area (bottom) there are ther 3 buttons, press the center button)

  1. 确保选择的方案对应于调试模式,因为有时 pch 文件可能有一些定义,以便仅在调试模式下进行日志记录(方案位于您选择 iPhone 模拟器/iOS 设备的位置的左侧)

  2. 在视图中选择调试区域(有 3 个视图按钮,在 Xcode 的右上角,按中心按钮)

  3. 选择“显示变量视图和控制台”(在调试区域(底部)有 3 个按钮,按中心按钮)

回答by codiac

I had the same issue and the problem was that I was building an Ad Hoc version (schema was for Ad Hoc build). The warnings disappeared when I built for debug.

我遇到了同样的问题,问题是我正在构建一个 Ad Hoc 版本(架构用于 Ad Hoc 构建)。当我为调试而构建时,警告消失了。

回答by Brian Mendez

Try changing the dropdown menu at the bottom of the console to 'All Output'.

尝试将控制台底部的下拉菜单更改为“所有输出”。

Screenshot

截屏

回答by Hunt3rDe

if you are using libraries like 'KScan' or 'iKEA' or 'kdc-scan', so it can happens that, they will call methods like this one 'redirectNSLogToDocuments'.

如果您正在使用诸如“KScan”或“iKE​​A”或“kdc-scan”之类的库,那么可能会发生这种情况,它们将调用诸如“redirectNSLogToDocuments”之类的方法。

in my case the object of 'iKEA' call the method 'CheckIfDeviceConnected' and this one redirect all nslog outputs to documents. after commenting out, all nslogs works again :)

在我的例子中,“宜家”的对象调用方法“CheckIfDeviceConnected”,这个将所有 nslog 输出重定向到文档。注释掉后,所有 nslogs 再次工作:)

hope this will be useful for some one.

希望这对某些人有用。

回答by Iphone_bharat

some steps :-

一些步骤:-

1) "Clean all targets" or delete your build and rebuild again.

1)“清理所有目标”或删除您的构建并再次重建。

2) If step 1 doesnt work , reinstall xcode

2) 如果步骤 1 不起作用,请重新安装 xcode