How to debug the preview in Xcode 13 or later - xcode

I can't work out how to debug a preview in Xcode 13.
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?

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

What is the meaning of this icon in Xcode 7 debug navigator?

This icon appears beside my program name in the debug navigator when running in the debugger in Xcode 7. I think it's new. I assume it means my lights are on. I checked, though, and they're off. Any other ideas?
It indicates an open crash report. If you open a crash report from the Organizer, it opens in the debug view and shows you the running threads and stack status from the crash report. I forgot I had one open. There's no way to close it that I can find.
Apple documented it in the Process View Display section.
image:https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/debugging_tools.html#//apple_ref/doc/uid/TP40015022-CH8-SW19
You can delete the crash report from the debug navigator by selecting the item and hitting backspace (←). This works actually with Xcode 11.5.

Xcode 6 to Xcode 11 - Detach the Console/Log Window

Is it possible to detach the console/log window in Xcode 6 to Xcode 9? If so, how do you detach it from the main console, into it's own window?
This question was previously asked for Xcode 4 but the answer doesn't work for Xcode 6 to Xcode 9 -
Stackoverflow - Same Question for Xcode 4
See the attached screenshot for illustration of the console/log view in question
Well, better late than never....
I found that I could maneuver and detach the console.
Add new tab.
Name the tab (eg Debugger).
In the new tab, expand the console so it fills the main window.
Right-click the new tab and select open in new window.
You'll have to quit Xcode and restart it to maintain the new window, rather than close projects or windows separately.
Apologize for the delay. Hope this is still useful..
UPDATE
This still works with Xcode 11.3!
To stop seperating the window : Xcode > Behaviors > Edit Behaviors
Then set as in the screenshot:
Solution without restarting Xcode. Thank #David DelMonte for illuminating me.
You can change Xcode behaviors configuration to open a new tab named Debugger in a separate window when project start running.
Then expand console view to full window in the debugger tab, Xcode will remember your reforms.

Don't show Xcode navigator on run

I have a dual-head setup for Xcode that I use for developing on iOS, with a split-pane editor and counterpart assistant on each screen. When I run a project it throws that away and takes over half my (active) screen with the debug navigator and console -- is there a way to have Xcode not show those on run? Or, even better, always show them on a particular screen?
Preferences->Behaviors. The default behaviour for "Running: Generates Output" is to switch to the debugger view and show the console - either turn that off or configure it to do something else.

How to get Xcode to show its startup screen again?

When I started Xcode I always got a screen that let me choose which project to open, or to start a new project, or a few other options. A few days ago I noticed it had a checkbox that was prechecked that said something like "Always show this screen on startup". Unfortunately, I unchecked it. I thought it would just reopen the last project I was editing but that's not what it does. Now Xcode just launches without opening any window at all so you have to go into its File menu, choose open, and find your project. I want to go back to the previous (default) behavior but I can't find any way to go back.
Does anyone know how to get that opening screen to show again? (It's not in preferences.)
From Xcode 4 and above versions, it's "Window" -> "Welcome to Xcode (⇧⌘1)".
On the older Xcode 3, it's "Help" -> "Welcome to Xcode".
If you want to see the window every time Xcode starts, please tick "Show this window when Xcode launches":
Beware that you need to hover over this window to see this checkbox.
Step 1
Start Xcode, go to the top navigation bar called Window, click on Welcome to Xcode it will show you the project screen:
Step 2
Look at the bottom of the welcome screen, there will be "show this window when Xcode launches", tick it:

Instruments 4.1 unresponsive to projects launched from Xcode 4.1 until pressing Cmd-Tab

If I open Instruments and select a standard application (e.g. Mail or MS Word) it has no issue.
If I am in Xcode and I go to Product > Profile (or press Cmd + I), it launches Instruments, allows me to select a template, and loads the standard screen. Then the downward arrow starts tracing to the right as it should, and the iOS simulator launches the program. However, nothing is plotted in Instruments. It shows no changes to anything no matter what the app is doing. I can't click anything in Instruments: no menu's, can't stop recording, can't open tabs, etc.
I randomly discovered that if I hit Cmd + Tab, Instruments will start behaving normally. This seems really strange to me. Either it's a bug or it's a hole in my knowledge about how to operate Instruments.
Strange bug is fixed in XCode 4.2!
The problem was the hidden password dialog, so sometime it works and sometimes not.
One of possible solutions was:
Run Instruments
Cmd Tab to Xcode covering the instruments. Cycle and hide messages until password dialog is found.
Close Xcode.
PS: I know it is a few years to late for the answer, I was just looking for unanswered questions. Just check as answered - > it's good for both of us. )

Resources