Flutter3.7升级后IntelliJ调试iOS/macOS时如何关闭控制台随机输出?
问题
升级至Flutter 3.7后,在iOS和macOS平台进入调试模式时,IntelliJ控制台会输出如下异常打印信息:
Performing hot restart... Syncing files to device macOS... Restarted application in 226ms. 1 HIToolbox 0x000000018f5c85c8 _ZN15MenuBarInstance22EnsureAutoShowObserverEv + 120 2 HIToolbox 0x000000018f5c8188 _ZN15MenuBarInstance14EnableAutoShowEv + 60 3 HIToolbox 0x000000018f5358bc _ZN15MenuBarInstance21UpdateAggregateUIModeE21MenuBarAnimationStylehhh + 1184 4 HIToolbox 0x000000018f5c8004 _ZN15MenuBarInstance19SetFullScreenUIModeEjj + 180 5 AppKit 0x00000001893b7d30 -[NSApplication _setPresentationOptions:instance:flags:] + 956 6 AppKit 0x000000018924d93c -[NSApplication _updateFullScreenPresentationOptionsForInstance:] + 404 7 CoreFoundation 0x0000000185e6a560 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148 8 CoreFoundation 0x000000018f508044 ___CFXRegistrationPost_block_invoke + 88 9 CoreFoundation 0x000000018f507f8c _CFXRegistrationPost + 440 10 CoreFoundation 0x0000000185e3bb64 _CFXNotificationPost + 708 11 Foundation 0x0000000186d2b38c -[NSNotificationCenter postNotificationName:object:userInfo:] + 88 12 AppKit 0x00000001893b82b4 spacesNotificationHandler + 96 13 SkyLight 0x000000018aaa5214 _ZN12_GLOBAL__N_123notify_datagram_handlerEj15CGSDatagramTypePvmS1_ + 896 14 SkyLight 0x000000018add14d4 _ZN21CGSDatagramReadStream26dispatchMainQueueDatagramsEv + 228 15 SkyLight 0x000000018add13d0 ___ZN21CGSDatagramReadStream15mainQueueWakeupEv_block_invoke + 28 16 libdispatch.dylib 0x0000000185c0c9dc _dispatch_call_block_and_release + 32 17 libdispatch.dylib 0x0000000185c0e504 _dispatch_client_callout + 20 18 libdispatch.dylib 0x0000000185c1cd1c _dispatch_main_queue_drain + 928 19 libdispatch.dylib 0x0000000185c1c96c _dispatch_main_queue_callback_4CF + 44 20 CoreFoundation 0x0000000185eb6d40 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 21 CoreFoundation 0x0000000185e747c0 __CFRunLoopRun + 2036 22 CoreFoundation 0x0000000185e73878 CFRunLoopRunSpecific + 612 23 HIToolbox 0x000000018f553fa0 RunCurrentEventLoopInMode + 292 24 HIToolbox 0x000000018f553de4 ReceiveNextEventCommon + 672 25 HIToolbox 0x000000018f553b2c _BlockUntilNextEventMatchingListInModeWithFilter + 72 26 AppKit 0x00000001890f984c _DPSNextEvent + 632 27 AppKit 0x00000001890f89dc -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728 28 AppKit 0x00000001890ece0c -[NSApplication run] + 464 29 AppKit 0x00000001890c4250 NSApplicationMain + 880 30 olahina 0x0000000102baf988 main + 12 31 dyld 0x0000000185a6be50 start + 2544
使用M1 MacBook Pro,已尝试在IntelliJ和Xcode中关闭所有控制台打印相关选项,但问题仍未解决。请问该异常输出是否与Xcode相关,能否将其关闭?
回答
这个输出确实和Xcode的底层调试机制相关,但它并非真正的应用异常,而是macOS系统UI组件(HIToolbox、AppKit等)在窗口状态切换时的内部调用栈日志,通常在Flutter调试模式下由Xcode的调试桥接器输出。
目前没有直接通过Xcode或IntelliJ设置彻底关闭的方法,但可以通过以下方式缓解:
- 在Flutter项目的
ios/Runner/Info.plist和macos/Runner/Info.plist中,添加NSFullScreenMenuItemHidden字段并设置为YES,减少菜单栏状态切换触发的日志输出 - 使用Flutter命令行工具启动调试,通过管道过滤冗余日志:
flutter run 2>&1 | grep -v "HIToolbox\|AppKit\|CoreFoundation" - 升级至Flutter 3.10及以上版本,官方在后续版本中优化了调试模式下的系统日志过滤逻辑,这类无意义的调用栈打印会被自动屏蔽
注:这类日志不会影响应用功能,只是调试时的冗余输出,无需担心应用稳定性问题。
内容的提问来源于stack exchange,提问作者Albert
相关产品推荐
相关产品推荐

