我的手机是iOS 10.1,xcode是8.1。
我通过终端构建并测试iOS App。我使用终端的xcodebuild xctestrun来运行我的单元测试。
xcodebuild -xctestrun {} -destination '{}' -derivedDataPath '{}' test-without-building"
在我的单元测试中,我需要生成另一个线程,我需要从该线程中记录信息。但是,我无法从此线程(不是主线程)中看到任何日志记录信息。我甚至看不到我从这个线程(不是主线程)中引发的异常类型。
当我在主线程
中引发异常时- (void)test1 {
// We always run the test in another thread because we need the main thread to spin for the UI.
dispatch_async(dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{
[NSException raise:@"ContentSyncException"
format:@"Timeout out waiting for %lu content", self.contentCount];
});
}
我得到了
libc++abi.dylib: terminating with uncaught exception of type NSException
但是如果我在主线程中引发相同的NSException
- (void)test1 {
[NSException raise:@"ContentSyncException"
format:@"Timeout out waiting for %lu content", self.contentCount];
// We always run the test in another thread because we need the main thread to spin for the UI.
dispatch_async(dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{
});
}
我得到了
*** Terminating app due to uncaught exception 'ContentSyncException', reason: 'Timeout out waiting for 3 content currently 0'
*** First throw call stack:
(0x186cf21b4 0x18572c55c 0x186cf20fc 0x1012c2070 0x1012c3464 0x185b7d1fc 0x185b7d1bc 0x185b8ba4c 0x185b8d34c 0x185b8d0ac 0x185d862a0 0x185d85d8c)
libc++abi.dylib: terminating with uncaught exception of type NSException
提前致谢