Debug Previews

I used to be able to "right click" on the play button for a preview, but in Beta 1 and 2 of Xcode 13 that isn't working (neither is control clicking). Any ideas how to debug a preview short of running app in the simulator?

Hi,

The ability to use a debugger for previews has unfortunately been removed. As you pointed out, the workaround is to run the app in the simulator.

Sorry for any inconvenience caused!

Thanks for clarifying @FrameworksEngineer.

If that is the case, it would be good to make a note at the top of this document: https://developer.apple.com/news/?id=8vkqn3ih

Since lots of SO and blog posts mention this "one weird trick" of right clicking the run button, something clear that mentions its deprecation would be good. Feedback Filed: FB9632206

Also: PSA for anyone coming here, a workaround I've started using is the Logger() api + Console app. Note that your log level seemingly must be .info or higher for Simulator / Preview logs to show on the host Mac's Console (whereas .debug is sufficient for attached physical devices.)

The XCode 13 RC release notes do mention following in the preview section:

Previews

...

Deprecations

Xcode 13 no longer includes a menu item in the Previews canvas for debugging a preview. Instead, use the Debug > Attach to Process menu item to attach the debugger to your previewed app. (73981969)

However, there are no instructions anywhere on how to find the process to attach to. I tried attaching to XCPreviewAgent process that seems to be spawned when I switch into run mode. Only to be hit by permission failures to debug.

Debug Previews
 
 
Q