热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何记录在Xcode中显示为运行时问题的警告?-HowtologawarningthatshowsupasaruntimeissueinXcode?

Xcode8or9starteddisplayingruntimeissues.Youseeapurpleiconatthetopofthewindow,and

Xcode 8 or 9 started displaying runtime issues. You see a purple icon at the top of the window, and a list in Issue Navigator, next to buildtime issues like compilation warnings and errors.

Xcode 8或9开始显示运行时问题。您会在窗口顶部看到一个紫色图标,并在“问题导航器”中看到一个列表,旁边是构建时间问题,如编译警告和错误。

enter image description here

enter image description here

The runtime issues I've seen are created by the system libraries. Is there a way for my own application code to generate these?

我见过的运行时问题是由系统库创建的。有没有办法让我自己的应用程序代码生成这些代码?

5 个解决方案

#1


1  

Yes! You'll see these if you do something that a sanitizer catches, like performing certain UI operations a background thread with Thread Sanitizer enabled. Having an ambiguous layout and pausing in the view debugger is also a way to get this to occur. Either way, seeing this occur in Apple's libraries isn't a good thing…

是!如果您执行清洁剂捕获的操作,您将看到这些内容,例如在启用了Thread Sanitizer的后台线程中执行某些UI操作。在视图调试器中具有模糊布局和暂停也是实现此目的的一种方法。无论哪种方式,看到苹果公司的图书馆出现这种情况并不是一件好事......

#2


1  

CocoaLumberjack framework can be used to capture Run times console logs as well as App's Background wakeup logs.

CocoaLumberjack框架可用于捕获运行时控制台日志以及App的后台唤醒日志。

https://github.com/CocoaLumberjack/CocoaLumberjack

https://github.com/CocoaLumberjack/CocoaLumberjack

https://github.com/phonegap/phonegap-plugin-push/issues/1988

https://github.com/phonegap/phonegap-plugin-push/issues/1988

This way you can capture purple warnings displayed in Xcode9 like below in a file that is maintained inside App Container:-

通过这种方式,您可以在App Container中维护的文件中捕获Xcode9中显示的紫色警告,如下所示: -

=================================================================

================================================== ===============

Main Thread Checker: UI API called on a background thread: -[UIApplication registerUserNotificationSettings:] PID: 2897, TID: 1262426, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21

主线程检查器:在后台线程上调用的UI API: - [UIApplication registerUserNotificationSettings:] PID:2897,TID:1262426,线程名称:(无),队列名称:com.apple.root.default-qos,QoS:21

#3


1  

It depends on you if you are doing any UI related stuff on other then main thread so system will generate for you else you can not manually generate it.

这取决于你,如果你在其他主线程上做任何UI相关的东西,所以系统将为你生成,你不​​能手动生成它。

All UI manipulations should be done in the Main Thread.

所有UI操作都应该在主线程中完成。

If you are not doing this so, in XCode 9 have feature called Main thread checker.

如果你不这样做,在XCode 9中有一个叫做主线程检查器的功能。

For more info, you can visit below url: https://developer.apple.com/documentation/code_diagnostics/main_thread_checker

有关详细信息,请访问以下网址:https://developer.apple.com/documentation/code_diagnostics/main_thread_checker

It is basically used to checks whether any UIKit related stuff is happening on a main thread or not ?, If failed to do so, it will produce issues at Runtime. So wrap your code in Main Thread block like below to avoid glitches and runtime warnings.

它基本上用于检查主线程上是否发生任何与UIKit相关的事情?如果不能这样做,它将在运行时产生问题。因此,将代码包装在主线程块中,如下所示,以避免毛刺和运行时警告。

You can Enable - Disable using this steps Edit Scheme... -> (Select your scheme) -> Diagnostics -> Disable 'Main thread checker'

您可以启用 - 使用以下步骤禁用编辑方案... - >(选择您的方案) - >诊断 - >禁用'主线程检查'

#4


1  

In XCode 8.3 and earlier you can use set breakpoint into any method of UIKit class like setNeedsDisplay() like below.

在XCode 8.3及更早版本中,您可以将set breakpoint用于UIKit类的任何方法,如下面的setNeedsDisplay()。

Also there is library in objective-c steipete class in which #import is used.

在objective-c steipete类中还有一个库,其中使用了#import

enter image description here

But in Xcode 9 below library Xcode.app/Contenets/Developer/usr/lib/libMainThreadChecker.dylib is available, Which handle for any relevant issues potentially performed out-of-main thread at runtime.

但是在Xcode 9下面,库Xcode.app/Contenets/Developer/usr/lib/libMainThreadChecker.dylib可用,它处理在运行时可能在主外线程执行的任何相关问题。

#5


0  

See here
Once you have deployed your app, either through the App Store or as an Ad Hoc or Enterprise build, you won't be able to attach Xcode's debugger to it. To debug problems, you need to analyze Crash Logs and Console output from the device.

请参阅此处通过App Store或Ad Hoc或Enterprise版本部署应用程序后,您将无法将Xcode的调试器附加到其中。要调试问题,您需要分析设备的崩溃日志和控制台输出。

Apple Watch crash logs will be available on the paired device and can also be obtained using the methods described below.

Apple Watch崩溃日志将在配对设备上提供,也可以使用下述方法获取。

For more information on writing rich NSLog statements, see Improved logging in Objective-C.

有关编写丰富的NSLog语句的更多信息,请参阅Objective-C中的改进日志记录。

Paste below example code into your project:

将示例代码粘贴到项目中:

NSMutableArray *someObject = [NSMutableArray array];
NSLog(@"%s:%d someObject=%@", __func__, __LINE__, someObject);
[someObject addObject:@"foo"];
NSLog(@"%s:%d someObject=%@", __func__, __LINE__, someObject);

推荐阅读
author-avatar
竹条蠢爱玉米
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有