隐藏奇怪的不需要的Xcode日志

当使用Xcode 8+并创build一个新的空白项目时,运行应用程序时会出现以下日志:

2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, enable_level: 0, persist_level: 0, propagate_with_activity: 0 2016-06-13 16:33:34.406323 TestiOS10[8209:100607] Created DB, header sequence number = 248 2016-06-13 16:33:34.409564 TestiOS10[8209:100611] subsystem: com.apple.UIKit, category: HIDEvents, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0 2016-06-13 16:33:34.504117 TestiOS10[8209:100607] Created DB, header sequence number = 248 2016-06-13 16:33:34.548023 TestiOS10[8209:100607] subsystem: com.apple.BaseBoard, category: MachPort, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0 2016-06-13 16:33:34.568458 TestiOS10[8209:100608] subsystem: com.apple.FrontBoard, category: Common, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0 

也许有人已经find了这个configuration来处理?

尝试这个:

1-从Xcode菜单打开:产品>scheme>编辑scheme

2-在您的环境variables上设置OS_ACTIVITY_MODE = disable

截图

在@rustyshelf的原始推文的基础上,并从iDevzilla的答案,这里是一个解决scheme,沉默模拟器的噪音,而不禁用设备的NSLog输出。

  1. 在Product> Scheme> Edit Scheme …> Run(Debug)下,将OS_ACTIVITY_MODE环境variables设置为$ {DEBUG_ACTIVITY_MODE},如下所示:

在这里输入图像描述

  1. 转到您的项目构build设置,然后单击+添加名为DEBUG_ACTIVITY_MODE的用户定义设置。 展开此设置并单击“debugging”旁边的“+”以添加特定于平台的值。 select下拉列表并将其更改为“Any iOS Simulator”。 然后将其值设置为“禁用”,如下所示:

在这里输入图像描述

推特有我的答案 – https://twitter.com/rustyshelf/status/775505191160328194

要停止Xcode 8 iOS模拟器的疯狂login,请在debuggingscheme中设置环境variablesOS_ACTIVITY_MODE = disable。

有效。

OS_ACTIVITY_MODE对我不起作用(这可能是因为我disabledisabled ,但并不那么自然?!?),或者至less没有阻止大量的消息。 所以这里是对环境variables的真正处理。

https://llvm.org/svn/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

 lldb_private::Error PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) { // Starting in Fall 2016 OSes, NSLog messages only get mirrored to stderr // if the OS_ACTIVITY_DT_MODE environment variable is set. (It doesn't // require any specific value; rather, it just needs to exist). // We will set it here as long as the IDE_DISABLED_OS_ACTIVITY_DT_MODE flag // is not set. Xcode makes use of IDE_DISABLED_OS_ACTIVITY_DT_MODE to tell // LLDB *not* to muck with the OS_ACTIVITY_DT_MODE flag when they // specifically want it unset. const char *disable_env_var = "IDE_DISABLED_OS_ACTIVITY_DT_MODE"; auto &env_vars = launch_info.GetEnvironmentEntries(); if (!env_vars.ContainsEnvironmentVariable(disable_env_var)) { // We want to make sure that OS_ACTIVITY_DT_MODE is set so that // we get os_log and NSLog messages mirrored to the target process // stderr. if (!env_vars.ContainsEnvironmentVariable("OS_ACTIVITY_DT_MODE")) env_vars.AppendArgument(llvm::StringRef("OS_ACTIVITY_DT_MODE=enable")); } // Let our parent class do the real launching. return PlatformPOSIX::LaunchProcess(launch_info); } 

因此,在环境variables(主要答案中的scheme截图中介绍的GUI方法) OS_ACTIVITY_DT_MODE设置为“NO”使其适用于我。

至于NSLog是系统消息,错误和你自己的debugging的倾倒地点:一个真正的日志logging方法可能被称为无论如何,例如https://github.com/fpillet/NSLogger

要么

喝新的库尔 – 援助: http : //asciiwwdc.com/2016/sessions/721 https://developer.apple.com/videos/play/wwdc2016/721/毫无疑问,检修整个后有一些绊倒loggingAPI。;

附录

无论如何, NSLog只是一个垫脚:

https://developer.apple.com/library/content/releasenotes/Miscellaneous/RN-Foundation-OSX10.12/

NSLog / CFLog

在大多数情况下,NSLog现在只是os_log的补充。

现在只需引用其他envvariables的来源。 相当不同的地方,这次来自苹果内部。 不知道他们为什么重叠。 [删除关于NSLog错误评论]

[编辑9月22日]:我不知道什么“释放”和“stream”做不同于“debugging”。 源不够。

https://github.com/macosforge/libdispatch/blob/8e63547ea4e5abbfe55c0c3064181c4950a791d3/src/voucher.c

 e = getenv("OS_ACTIVITY_MODE"); if (e) { if (strcmp(e, "release") == 0) { mode = voucher_activity_mode_release; } else if (strcmp(e, "debug") == 0) { mode = voucher_activity_mode_debug; } else if (strcmp(e, "stream") == 0) { mode = voucher_activity_mode_stream; } else if (strcmp(e, "disable") == 0) { mode = voucher_activity_mode_disable; } } 

这在Xcode版本8.0 beta 2(8S162m)中对我来说还是不能修复的,额外的日志也出现在Xcode控制台

**编辑8/1/16:在Xcode 8 Beta 4(8S188o)的发行说明中已经确认这是一个仍然存在的问题 。

Xcode 8 beta 4中的已知问题 – IDE

debugging

•在Simulator中debugging应用程序时,Xcodedebugging控制台会显示来自系统框架的额外logging。 (27331147,26652255)

据推测,这将通过全球机制的释放来解决。 在那之前耐心,虽然不理想,但我使用的解决方法是…

与之前的答案类似,我不得不:

  • 在我的打印日志前加上某种特殊字符(如*或^或!等)

  • 然后使用控制台窗格右下angular的search框,通过input我select的特殊字符来过滤我的控制台日志,以使控制台按预期显示我的打印日志

安慰

请find以下步骤。

  1. selectProduct => Scheme => Edit Scheme或使用快捷键: CMD + <
  2. 从左侧selectRun选项。
  3. 在环境variables部分,添加variablesOS_ACTIVITY_MODE = disable

欲了解更多信息,请find下面的GIF表示。

编辑方案

我的解决scheme是在断点中使用debugging器命令和/或日志消息

在这里输入图像描述

并将控制台的输出从“ 所有输出 ”更改为“ debugging器输出”

在这里输入图像描述

这与Xcode 8 Beta发行注记中的一个已知问题有关(也被问到WWDC的一名工程师)。

在Watch模拟器中debuggingWatchOS应用程序时,操作系统可能会产生过多的无用日志。 (26652255)

目前没有可用的解决方法,您必须等待新版本的Xcode。

编辑7/5/16:这应该是固定的Xcode 8 Beta 2:

解决了Xcode 8 beta 2 – IDE

debugging

  • 在模拟器上debugging应用程序时,日志是可见的。 (26457535)

Xcode 8 Beta 2发行说明

好的。 这件事似乎有很多骚动,所以我会给你一个坚持它的方法,而不是使用这个scheme。 我将专门针对iOS模拟器,但这也可能需要应用于位于不同目录中的电视模拟器。

导致所有这些东西的问题是位于Xcode目录内的plists。 有一个进程叫做configd_sim,当Sim启动时,读取plists并打印debugging信息,如果plists指定他们应该被logging。

plists位于这里:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Preferences/Logging/Subsystems

如果你正在玩一个testing版,请注意,目录会有所不同。

你会在这个目录中看到许多plists。 现在,构build并运行您的应用程序并观察日志。 您正在查找子系统紧随其后的内容部分。 这是紧接着的名字,代表相应的问题plist。

在这里输入图像描述

从那里,或者修改plist来淘汰包含"Enable" => "Default"键/值的字典的debugging[Level]键/值,或者只是简单地删除plist。 请注意,由于它们位于Xcode应用程序中,因此您将需要作为root用户才能执行这些操作。

plutil -p命令也可能对你有用。 即

 plutil -p /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Preferences/Logging/Subsystems/com.apple.BackBoardServices.fence.plist 

这给了我一个有问题的plists其中包含:

{ "DEFAULT-OPTIONS" => { "Level" => { "Enable" => "Default" }}}

祝你好运 :]

这已经不再是xcode 8.1 (已testing版本8.1 beta(8T46g))的一个问题。 您可以从您的scheme中删除OS_ACTIVITY_MODE环境variables。

https://developer.apple.com/go/?id=xcode-8.1-beta-rn

debugging

•在Simulator中debugging应用程序时,Xcode Debug Console不再显示系统框架中的额外日志logging。 (26652255,27331147)

这个解决scheme一直在为我工作:

  1. 在模拟器中运行应用程序
  2. 打开系统日志( + /

这将转储出所有的debugging数据和你的NSLogs。

只要过滤你的NSLog语句:

  1. 每个符号前缀,例如: NSLog(@"^ Test Log")
  2. 使用右上angular的search框筛选结果,在上面的情况下使用“^”

这是你应该得到的:

控制台的屏幕截图