本文介绍了iOS 10不打印NSLogs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Xcode 8.0 beta(8S128d)上,NSLog上没有任何内容. printf不变

Nothing prints from NSLog on Xcode 8.0 beta (8S128d). printf is unchanged

这是我的代码:

NSLog(@"hello from NSLog");
printf("hello from printf");

这是iOS 9 Simulator上的输出:

Here's the output on iOS 9 Simulator:

2016-06-17 09:49:10.887 calmapp-dev[28517:567025] hello from NSLog
hello from printf

这是iOS 10 Simulator上的输出:

Here's the output on iOS 10 Simulator:

hello from printf

推荐答案

可能是您在Scheme环境变量中添加了属性"OS_ACTIVITY_MODE":"disable"(以隐藏来自模拟器的OS输出)并忘记了它,现在正在实际设备上运行.

It could be that you added the property "OS_ACTIVITY_MODE": "disable" in the Scheme environment variables (to hide OS output from the simulator) and forgot about it, and now are running on a real device.

在Xcode 8中:

Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment Variables

仅添加OS_ACTIVITY_MODE并进行检查(不添加值)

Only add OS_ACTIVITY_MODE and check it(Don't add a value)

摘要:这是Xcode 8 + iOS10的错误,我们可以通过以下方式解决它:

Summary:This is a bug of Xcode 8 + iOS10, we can solve it in this way:

  • 使用模拟器时,添加名称"OS_ACTIVITY_MODE"和值"disable"并进行检查.

  • When using the simulator, add the Name "OS_ACTIVITY_MODE" and the Value "disable" and check it.

在真实设备上时,仅添加"OS_ACTIVITY_MODE"并进行检查(不添加值).您将在Xcode8控制台中看到NSLog.

When on a real device, only add "OS_ACTIVITY_MODE" and check it(Don't add the Value).You will see the NSLog in the Xcode8 Console.

这篇关于iOS 10不打印NSLogs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 03:24