skip to Main Content

I can’t work out how to debug a preview in Xcode 13.

preview

Documentation for Xcode 11 and Xcode 12 has conflicting advice like

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

I’ve tried it all – 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


  1. 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

    Login or Signup to reply.
  2. 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)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search