Xcode - is it possible to debug crashes in the Interface Builder's Live Rendering process (IBDesignable)?
I watched the WWDC video again (§411 @22:00 or so). You have to
- edit a view in IB, and set its custom class to a class in your codebase
- set breakpoints as desired in your custom class
- select the view in IB, then select Editor -> "Debug Selected Views" (at bottom)
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).
(tools note: Xcode 8.2, macOS Sierra)
I had a very different failure than yours: I had a crash in code that resulted in an IB error in Xcode:
error: IB Designables: Failed to update auto layout status: The agent crashed
To debug this on macOS Sierra, open Console.app, and open "User Reports" in the right sidebar. Find the "IBDesignablesCocoaTouch*" crashes, and select the applicable one. This gave me the code-level info I needed to diagnose it.
Crashed Thread: 0
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Application Specific Information:
CoreSimulator 375.21 - Device: IBSimDeviceTypeiPad2x - Runtime: iOS 10.3 (14E8301) - DeviceType: IBSimDeviceTypeiPad2x
Thread 0 Crashed:
0 libswiftUIKit.dylib 0x000000021a2ddead _TToFE5UIKitCSo7UIImagecfT24imageLiteralResourceNameSS_S0_ + 205
1 libswiftUIKit.dylib 0x000000021a2ddcef _TFE5UIKitCSo7UIImageCfT24imageLiteralResourceNameSS_S0_ + 79
2 com.company.App 0x0000000216df74ad _TZFC10App21ControlsP33_F7118662B6663018C7DD0DEBB6FDD87511buttonImagefT8forStateOS_25State_CSo7UIImage + 109 (Controls.swift:121)
…
(In my case, Interface Builder was failing to load an image literal. I had to implement this workaround: xcode 6 IB_DESIGNABLE- not loading resources from bundle in Interface builder)