Xcode 9似乎报告了许多对UIApplication属性的主线程调用。即使UI没有被更新,由于日志的扩展,它会产生一个默认环境,因此特别麻烦。
4 TestApp 0x0000000101c262e0 __39-[ViewController viewDidLoad]_block_invoke + 196
5 libdispatch.dylib 0x0000000102279654 _dispatch_call_block_and_release + 24
6 libdispatch.dylib 0x0000000102279614 _dispatch_client_callout + 16
7 libdispatch.dylib 0x0000000102289008 _dispatch_queue_serial_drain + 716
8 libdispatch.dylib 0x000000010227ce58 _dispatch_queue_invoke + 340
9 libdispatch.dylib 0x000000010228a1c4 _dispatch_root_queue_drain_deferred_wlh + 412
10 libdispatch.dylib 0x00000001022917fc _dispatch_workloop_worker_thread + 868
11 libsystem_pthread.dylib 0x00000001ac6771e8 _pthread_wqthread + 924
12 libsystem_pthread.dylib 0x00000001ac676e40 start_wqthread + 4
答案 0 :(得分:5)
答案 1 :(得分:0)
还要检查ARKit template Xcode project Main Thread Checker log console。
如果从另一个线程调用UIApplication或UIApplicationDelegate方法,则可以像CGN答案中一样禁用检查线程,但是它将完全禁用此检查器。您也可以将必要的子类化,并在主线程上调用超类的方法。这样,您仍然可以在代码的其他地方使用Main Thread Sanitizer