how to debug a preview in Xcode 13 or Xcode 12

Viewed 6294

so - I can't for the life of me work out how to debug a preview in Xcode 13

preview

I can find all sorts of documentation for Xcode 11, which is very different - and even documentation for Xcode 12 with all sorts of conflicting advice like

  • right click the run button and you'll get a menu
  • control/command/option click run
  • long click the run

Well - I've tried all of those - and put breakpoints on almost every line of code in my preview / view / init functions - and however I hit run, it just... runs... - so I see the preview, but no breakpoints are hit - no print statements come out in the console - no cool expanded ui display appears - and no menus appear.

any ideas?

2 Answers

It looks like Apple has chosen to remove the ability to debug Xcode Previews in Xcode 13 with no guidance as to if/when it will be brought back.

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!

Posted 1 month ago by Frameworks Engineer 

https://developer.apple.com/forums/thread/683773

You can attach the Debugger to the Preview Process like explained here

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)

Related