Xcode 11 debugger is extremely slow - A known problem?

IosXcode

Ios Problem Overview


Since I updated to the latest Xcode version 11.0 (11A420a) the debugging is extremely slow and cumbersome.

EDIT: After updating to 11.1 GM (11A1027) the problem is still the same.

Compiling a project and running it in simulator or on a device is no problem. However when reaching a breakpoint Xcode becomes more or less unusable:

  • Program execution stops immediately when the breakpoint is reached. However Xcode needs up to 30 seconds to show the position in the code window and another minute or so to load the content of the variable view (which shows the values and states of the variables available at the breakpoint).
  • If I use the Step into or Step over features it takes up to a minute to perform the next step and again another minute to load the variables.

I am running Xcode on a Mac mini 2018 with a 3.2 GHz i7 and 32 GB ram. I have used Xcode 10 on the same machine before without any problems.


Searching for "Xcode slow" brings up a ton of threads and possible solutions of course. From my years as iOS Developer I know that Xcode never was the fastest and stable program. However it was never as bad as now.

Unfortunately none of the know tricks (restarting Xcode or the Mac, cleaning the project, cleaning the Xcode library folders, etc. had any effect,

So the big question is:

Is this a known problem in Xcode 11? Are there any known solutions?

Ios Solutions


Solution 1 - Ios

Well I had the same problem and recently figured out that I just forgot to disable diagnostics for my scheme

enter image description here

Open your run configurations -> Manage schemes -> Edit scheme -> Run -> Diagnostics tab

Solution 2 - Ios

I've seen some performance improvements when using the Whole versus Incremental Compilation behavior. Additionally running on Mojave and Catalina should both be showing performance issues. Specifically since the Canvas preview and other new features require more CPU intensity than the last version of Xcode, I would expect Mojave performance to be lower when using Xcode 11 (as it's not optimized for this version of the OS). With Catalina being in Beta, I'd expect to see additional issues as well. I haven't taken specific measures other than the eye-test. The initial run on Whole Compilation is slow but seems to get better thereafter.

Quick help states:

> Summary > > This setting controls the way the Swift files in a module are rebuilt. > * Incremental: Only rebuild the Swift source files in the module that are out of date, running multiple compiler processes as needed. * > Whole Module: Always rebuild all Swift source files in the module, in a single compiler process. Declaration > > SWIFT_COMPILATION_MODE Value Type > > Enumeration (String)

Solution 3 - Ios

In my case (XCode 11.x, MacOS 10.15.2) I've found that the extreme debugger slowness is only triggered if I single-step while another single-step operation is in progress, i.e. I press the step button too quickly. My current workaround is to avoid doing that.

Pure speculation but perhaps it's triggered by XCode/LLDB trying to service multiple breakpoints concurrently? Try removing all breakpoints but one and see if that helps things.

In case it's relevant: I mostly work with C++ in XCode, with a little Obj-C here and there. I don't use Swift at all at present.

Solution 4 - Ios

I had 238 unused breakpoints set. When I deleted them, it's fast again (even with diagnostics turned on.)

Solution 5 - Ios

For me, deleting ~/.lldb solved this problem.

Solution 6 - Ios

Have you tried running Xcode in safe mode? It's not ideal, but this was the only way I could get it to run efficiently. That is until the recent Catalina update where my device is no longer detected in safe mode. So I'm back to square one now.

Solution 7 - Ios

I've found the same problems in two different cases:

  1. the app is not launched by Xcode, i.e. the flag "Wait for executable to be launched" is set inside the Info panel of the Scheme Run settings;

  2. the option "Launch due to a background fetch event" is selected in the scheme settings (but this is not the default)

Xcode option position

Xcode 11.2.1 (11B500)

Solution 8 - Ios

Please try to uncheck: Parallelize Build on each target in Edit Scheme. It 'll save time to build If your project has many targets.

Edit Scheme:

enter image description here

Solution 9 - Ios

I've been dealing with this forever and finally figured it out. It was these lines in my ~/.lldbinit file:

break set -F '-[UIView layoutIfNeeded]' -c '!(BOOL)[NSThread isMainThread]' -L objc
break set -F '-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]' -c '!(BOOL)[NSThread isMainThread]' -L objc

I commented those lines out and now it's almost as fast as without the debugger!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndrei HerfordView Question on Stackoverflow
Solution 1 - IosGennadiy RyabkinView Answer on Stackoverflow
Solution 2 - IosTommie C.View Answer on Stackoverflow
Solution 3 - IosReuben ScrattonView Answer on Stackoverflow
Solution 4 - Iosuser2989332View Answer on Stackoverflow
Solution 5 - IosVincent SitView Answer on Stackoverflow
Solution 6 - IosDinoView Answer on Stackoverflow
Solution 7 - IosGiorgio DainoView Answer on Stackoverflow
Solution 8 - IosThien PhamView Answer on Stackoverflow
Solution 9 - IosJohn ScaloView Answer on Stackoverflow