NSLog 不打印到控制台
我有一个 Xcode 项目,我已经工作了几个月了。我从来没有遇到过 NSLog 问题,但升级到 Xcode 4.2 后,控制台上不会记录任何内容。我什至尝试将其扔到 viewDidLoad: 中
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Can anyone hear me?");
,但什么也没有。还有其他人遇到这个问题或知道解决方案吗?
I have an Xcode project I've been working on for months. I've never had a problem with NSLog, but after upgrading to Xcode 4.2 nothing will log to the console. I even tried throwing this in viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Can anyone hear me?");
And nothing. Is anyone else having this problem or know a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
嗯,这很尴尬。控制台不知何故被停用,我实际上正在观察变量窗口。按 Shift + + C 就可以了。
非常感谢 Robert King 在这个帖子上的发言:
https://devforums.apple.com/message/565880 #565880
Well, this is embarrassing. The console got deactivated somehow and I was actually watching the variables window. Pressing Shift + + C did the trick.
Many thanks to Robert King on this thread:
https://devforums.apple.com/message/565880#565880
这是Xcode8 + iOS10的一个bug,我们可以这样解决:
在模拟器上,添加Name
OS_ACTIVITY_MODE
和Value变量
禁用
并检查它(产品 -> 方案 -> 编辑方案 -> 运行 -> 参数 -> 环境)。在设备上时,仅添加
OS_ACTIVITY_MODE
并勾选(不添加Value)。您将在 Xcode8 控制台中看到 NSLog。This is a bug of Xcode8 + iOS10, we can solve it in this way:
When on simulator, add the Name
OS_ACTIVITY_MODE
and the ValueVariables
disable
and check it (Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment).When on device, only add
OS_ACTIVITY_MODE
and check it(don't add the Value). You'll see the NSLog in the Xcode8 Console.在iOS10中,很多系统日志记录都显示在控制台上。可以通过在方案的运行参数中包含 OS_ACTIVITY_MODE = 禁用来禁用此功能。
但是对于 iOS10,将不再显示 NSLog 消息。
在较低的 iOS 版本中,消息仍会显示。因此,也许对于大多数测试用例,您可以使用较低的 iOS 版本。
否则,您可以包含一个 Swift 函数来打印(打印函数)您的文本,这在 iOS10 中工作正常。
在iOS10.0.2和iOS9.3上测试
In iOS10, a lot of system logging is displayed on the console. This can be disabled by including the OS_ACTIVITY_MODE = disabled in the Run Arguments for your scheme
However for iOS10, NSLog messages will not be displayed anymore.
In lower iOS versions the messages will still be displayed. So maybe for most test cases you can use a lower iOS version.
Otherwise you can include a Swift function which prints (print function) your text, this is working okay in iOS10.
Tested on iOS10.0.2 and iOS9.3
我的问题是我选择了调试器输出。一旦我将其更改为所有输出或目标输出,NSLogs 就会显示正常。
如果这让您感到困惑,它位于调试区域的左侧。
My issue is that I have Debugger Output selected. Once I changed it to either All output or target output NSLogs appear fine.
In case this confuses you its on the left of the Debug area.
我有同样的问题。
诀窍是从项目中搜索并删除下面提到的行。
搜索整个项目并将其删除。
I had the same issue.
The trick is to search and remove the below mentioned line from the project.
Search the entire project and remove it.
我刚刚经历过这个,所以还有一件事需要检查。
->确保您没有在日志输出下方的过滤器字段中输入任何内容。因此,就我而言,我在记录器中搜索一个术语,却忘记从“过滤器”文本字段中删除搜索到的术语。卫生部!
I just experienced this, so here's another thing to check.
-> Make sure you don't have anything typed in the Filter field below the Log Output. So, in my case I was searching for a term in the logger and forgot to delete the searched terms out of the Filter text field. DOH!
我的问题是我不小心切断了应用程序委托(委托 - 文件所有者)的引用出口。
My issue was that I'd accidentally severed the referencing outlet from App Delegate (delegate - file's owner).
升级到 macOS 的 Xcode 15.0.1 后,也出现了类似的问题。 NSLog 未打印到控制台。对我有用的这个问题的解决方案如下所述。请参阅https://lapcatsoftware.com/articles/2023/10/5.html< /a> , https://developer.apple.com/forums/thread/742594 了解更多信息。
带有键“IDELogRedirectionPolicy”的环境变量价值
“oslogToStdio”
控制台到“Xcode”或“终端”
This similar issue was observed after upgrade to Xcode 15.0.1 for macOS. NSLog was not printing to console. The solution to this issue that worked for me is as mentioned below. Refer to https://lapcatsoftware.com/articles/2023/10/5.html , https://developer.apple.com/forums/thread/742594 for more info.
environment variable with key "IDELogRedirectionPolicy" & value
"oslogToStdio"
the console to "Xcode" or "Terminal"