简体   繁体   English

Xcode 9.0 Swift 04(由于未捕获的异常“ NSInternalInconsistencyException”而终止应用程序,原因:“仅在主线程上运行!”)

[英]Xcode 9.0 Swift 04 (Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!')

Main Thread Checker: UI API called on a background thread: -[UIView init]
PID: 460, TID: 62011, Thread name: (none), Queue name: com.apple.root.background-qos, QoS: 9
Backtrace:
4   IQKeyboardManagerSwift              0x00000001025c8274 _T0So11UITextFieldCABycfcTO + 28
5   IQKeyboardManagerSwift              0x00000001025a8360 _T0So11UITextFieldCABycfC + 68
6   IQKeyboardManagerSwift              0x00000001025a7e90 _T022IQKeyboardManagerSwift0aB0CACycfc + 5196
7   IQKeyboardManagerSwift              0x00000001025a838c _T022IQKeyboardManagerSwift0aB0CACycfcTo + 28
8   IQKeyboardManagerSwift              0x00000001025a6a3c _T022IQKeyboardManagerSwift0aB0CACycfC + 32
9   IQKeyboardManagerSwift              0x00000001025c5920 globalinit_33_1804EA4A44CDC62F5B66EAD58B4692DC_func2 + 24
10  libdispatch.dylib                   0x00000001043e545c _dispatch_client_callout + 16
11  libdispatch.dylib                   0x00000001043e617c dispatch_once_f + 120
12  IQKeyboardManagerSwift              0x000000010259c4cc _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ6StaticL_V02kbB0ACfau + 56
13  IQKeyboardManagerSwift              0x000000010259c46c _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ + 24
14  eBeePartners                        0x0000000100c9ef7c _T012eBeePartners11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tFyycfU_ + 52
15  eBeePartners                        0x0000000100bd18c0 _T0Ix_IyB_TR + 48
16  libdispatch.dylib                   0x00000001043e549c _dispatch_call_block_and_release + 24
17  libdispatch.dylib                   0x00000001043e545c _dispatch_client_callout + 16
18  libdispatch.dylib                   0x00000001043f6cd8 _dispatch_root_queue_drain + 1004
19  libdispatch.dylib                   0x00000001043f6880 _dispatch_worker_thread3 + 136
20  libsystem_pthread.dylib             0x0000000181dab130 _pthread_wqthread + 1268
21  libsystem_pthread.dylib             0x0000000181daac30 start_wqthread + 4
2017-09-22 12:36:11.268059+0800 eBeePartners[460:62011] [reports] Main Thread Checker: UI API called on a background thread: -[UIView init]
PID: 460, TID: 62011, Thread name: (none), Queue name: com.apple.root.background-qos, QoS: 9
Backtrace:
4   IQKeyboardManagerSwift              0x00000001025c8274 _T0So11UITextFieldCABycfcTO + 28
5   IQKeyboardManagerSwift              0x00000001025a8360 _T0So11UITextFieldCABycfC + 68
6   IQKeyboardManagerSwift              0x00000001025a7e90 _T022IQKeyboardManagerSwift0aB0CACycfc + 5196
7   IQKeyboardManagerSwift              0x00000001025a838c _T022IQKeyboardManagerSwift0aB0CACycfcTo + 28
8   IQKeyboardManagerSwift              0x00000001025a6a3c _T022IQKeyboardManagerSwift0aB0CACycfC + 32
9   IQKeyboardManagerSwift              0x00000001025c5920 globalinit_33_1804EA4A44CDC62F5B66EAD58B4692DC_func2 + 24
10  libdispatch.dylib                   0x00000001043e545c _dispatch_client_callout + 16
11  libdispatch.dylib                   0x00000001043e617c dispatch_once_f + 120
12  IQKeyboardManagerSwift              0x000000010259c4cc _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ6StaticL_V02kbB0ACfau + 56
13  IQKeyboardManagerSwift              0x000000010259c46c _T022IQKeyboardManagerSwift0aB0C06sharedB0ACyFZ + 24
14  eBeePartners                        0x0000000100c9ef7c _T012eBeePartners11AppDelegateC11applicationSbSo13UIApplicationC_s10DictionaryVySC0F16LaunchOptionsKeyVypGSg022didFinishLaunchingWithI0tFyycfU_ + 52
15  eBeePartners                        0x0000000100bd18c0 _T0Ix_IyB_TR + 48
16  libdispatch.dylib                   0x00000001043e549c _dispatch_call_block_and_release + 24
17  libdispatch.dylib                   0x00000001043e545c _dispatch_client_callout + 16
18  libdispatch.dylib                   0x00000001043f6cd8 _dispatch_root_queue_drain + 1004
19  libdispatch.dylib                   0x00000001043f6880 _dispatch_worker_thread3 + 136
20  libsystem_pthread.dylib             0x0000000181dab130 _pthread_wqthread + 1268
21  libsystem_pthread.dylib             0x0000000181daac30 start_wqthread + 4
2017-09-22 12:36:22.758673+0800 eBeePartners[460:61967] [BoringSSL] Function nw_protocol_boringssl_input_finished: line 1389 Peer disconnected during the middle of a handshake. Sending errSSLFatalAlert(-9802) alert
2017-09-22 12:36:22.813732+0800 eBeePartners[460:61967] TIC TCP Conn Failed [2:0x1c0166900]: 3:-9802 Err(-9802)
2017-09-22 12:36:22.848609+0800 eBeePartners[460:61719] [MC] Lazy loading NSBundle MobileCoreServices.framework
2017-09-22 12:36:22.854700+0800 eBeePartners[460:61719] [MC] Loaded MobileCoreServices.framework
2017-09-22 12:36:22.864960+0800 eBeePartners[460:61719] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-09-22 12:36:22.898137+0800 eBeePartners[460:62011] *** Assertion failure in void _UIPerformResizeOfTextViewForTextContainer(NSLayoutManager *, UIView<NSTextContainerView> *, NSTextContainer *, NSUInteger)(), /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIFoundation/UIFoundation-543/UIFoundation/TextSystem/NSLayoutManager_Private.m:1619
2017-09-22 12:36:23.117424+0800 eBeePartners[460:62011] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!'
*** First throw call stack:
(0x18217fd38 0x181694528 0x18217fc0c 0x182b0ec90 0x18c65a70c 0x18c65a194 0x18c689e4c 0x18c689b08 0x18c6b3f88 0x18b8ebf28 0x18b5b1218 0x18c1e697c 0x18b6613ec 0x1025c8274 0x1025a8360 0x1025a7e90 0x1025a838c 0x1025a6a3c 0x1025c5920 0x1043e545c 0x1043e617c 0x10259c4cc 0x10259c46c 0x100c9ef7c 0x100bd18c0 0x1043e549c 0x1043e545c 0x1043f6cd8 0x1043f6880 0x181dab130 0x181daac30)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

How to debug this code? 如何调试此代码?

I also had this error ONLY AFTER upgrading to Xcode9/Swift4. 我也只有在升级到Xcode9 / Swift4之后才出现此错误。 As mentioned in comments, the reason is calling ui-operations in background thread. 正如评论中提到的,原因是在后台线程中调用ui操作。 I don't know why it has been working until upgrading. 我不知道为什么它在升级之前一直有效。

How to debug 如何调试

You are seeing this error on Xcode which process frozen by debugger, right? 您在Xcode上看到此错误,该错误由调试器冻结,对吗? Then, the left side panel (called "debug navigator") is showing call stack and indicating the line where the app crashed. 然后,左侧面板(称为“调试导航器”)显示调用堆栈并指示应用程序崩溃的行。 You can click one of them and get the code. 您可以单击其中之一并获取代码。

In my case 就我而言

The cause of error is performSegue attempted to run on the main thread in my case. 错误原因是在我的情况下, performSegue试图在主线程上运行。

func downloadHandler() {
    DispatchQueue.global(qos: .default).async(execute: {

        DispatchQueue.main.async(execute: {
            self.labelMessage.text = "Unzipping downloaded data..."
        })

        /* Unzipping something... */

        // WRONG: This causes error
        // self.performSegue(withIdentifier: "toViewController", sender: nil)

        // FIXED: performSegue should be run on main thread.
        DispatchQueue.main.async(execute: {
            self.performSegue(withIdentifier: "toViewController", sender: nil)
        })
    })
}

Double check your DispatchQueue . 仔细检查您的DispatchQueue It would be better to start at where debugger stopped. 最好从调试器停止的地方开始。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于未捕获的异常“ NSInternalInconsistencyException”而终止应用程序,原因:“仅在主线程上运行!” - Terminating app due to an uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!' 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“线程违规:预期主线程” - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'threading violation: expected the main thread' 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,- Swift 3 - Terminating app due to uncaught exception 'NSInternalInconsistencyException',- Swift 3 由于未捕获的异常“NSInternalInconsistencyException (Swift)”而终止应用程序 - Terminating app due to uncaught exception 'NSInternalInconsistencyException (Swift) 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在捆绑 xcode 7 中加载 NIB - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle xcode 7 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“意外的启动状态” - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unexpected start state' 由于未捕获的异常“ NSInternalInconsistencyException”而终止应用程序,原因:删除当前字典 - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: deleting current dictionary Xcode无法编译“由于未捕获的异常&#39;NSInternalInconsistencyException&#39;而终止应用程序” - Xcode not compiling “Terminating app due to uncaught exception 'NSInternalInconsistencyException'” 由于存在未捕获的异常“ NSInternalInconsistencyException”而终止应用 - Terminating app due to uncaught exception 'NSInternalInconsistencyException' at 由于未捕获的异常&#39;NSInternalInconsistencyException&#39;错误而终止应用程序 - Terminating app due to uncaught exception 'NSInternalInconsistencyException' error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM