Xcode-是否可以在Interface Builder的实时渲染过程(IBDesignable)中调试崩溃? [英] Xcode - is it possible to debug crashes in the Interface Builder's Live Rendering process (IBDesignable)?

查看:95
本文介绍了Xcode-是否可以在Interface Builder的实时渲染过程(IBDesignable)中调试崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

是否可以设置断点并调试Xcode/Interface Builder的Live Rendering执行的代码?也就是说,我正在使用IBDesignable和IBInspectable属性来影响视图,因为该视图在界面构建器情节提要板中呈现,并且希望能够调试"IB崩溃"错误.除了prepareForInterfaceBuilder的部分之外,我从WWDC的会议上都不会记得这一点.

Is it possible to set breakpoints and debug code executed by Xcode / Interface Builder's Live Rendering? That is, I am using the IBDesignable and IBInspectable attributes to affect the view as it is rendered in an interface builder storyboard, and would like to be able to debug "IB crashed" errors. I don't recall this from the WWDC session, other than the section on prepareForInterfaceBuilder.

上下文

我最近开始看到许多错误报告,当尝试渲染我的代码时IB崩溃了.最终,我将其追溯到情节提要中链接的我的其中一个视图中layoutSubviews中原本纯真的代码行. IB的特定问题-呈现实时视图时,在设置所有视图的子视图属性之前将其称为layoutSubviews(这本身就是一个单独的问题).这与模拟器和设备形成对比,在模拟器和设备中,视图是在第一次调用layoutSubviews之前设置的.简而言之,它涉及散布一堆文件以查找令人讨厌的更改.可以说,如果可以设置断点并捕获崩溃,我可以很快发现问题.

I recently started seeing a number of errors reporting that IB crashed when attempting to render my code. I ultimately traced it to an otherwise innocent line of code in layoutSubviews in one of my views that was linked from the storyboard. The specific problem that IB - when rendering live views, called layoutSubviews before setting all the view's child view properties (which seems like a separate problem, in and of itself). This contrasted with the simulator and device, in which the views were set ahead of the first call to layoutSubviews. Long story short though, it involved diffing a bunch of files to find the offending change. Suffice to say, I could have found the problem quickly if it were possible to set breakpoints and trap the crash.

有没有人知道如何调试和/或通常捕获这些问题,或者访问尚不可用?

Has anyone figured out how to debug and/or generally trap these problems, or is that access not yet available?

推荐答案

我再次观看了WWDC视频(§411@ 22:00左右).你必须

I watched the WWDC video again (§411 @22:00 or so). You have to

  • 在IB中编辑视图,并将其自定义类设置为代码库中的类
  • 根据需要在自定义类中设置断点
  • 在IB中选择视图,然后选择编辑器"->调试选定的视图"(在底部)

奇怪的是,在今天的测试中,它是通过(initWith)Frame而不是(initWith)Coder创建视图的.这会导致随后的约束配置逻辑失败,因为尚未设置子视图(因为它们将被调用'withCoder).

Oddly, in my tests today, it is creating my view via (initWith)Frame instead of (initWith)Coder. This causes subsequent constraint configuration logic to fail as the sub views have not been set (as they would had 'withCoder been called).

这篇关于Xcode-是否可以在Interface Builder的实时渲染过程(IBDesignable)中调试崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆