9

My Xcode Version 13.2.1 (13C100) got an unknown issue. I did several things like delete Xcode, new install Xcode, restore from backup nothing make any change! Currently, the project can be built and run in the simulator, but not in the preview window! it gives a message:

Cannot preview in this file - Timed out waiting for connection to DTServiceHub after 15.0 seconds.

What is the issue here any idea? iMac becomes very slow when I taped the resume button. Please Help!

enter image description here

Debashish M
  • 193
  • 3
  • 13

7 Answers7

6

I had a similar problem and was solved when I turned of Automatically refresh canvas

enter image description here

Ramy Rizkalla
  • 164
  • 1
  • 7
  • This does not work for me. – Debashish M Jan 06 '22 at 17:06
  • This works on Xcode 14.2. Interestingly when I turn this off, preview loads instantly. With this on, it takes forever to build for previews (and that build fails). If I turn this on again, I get buid error in preview again. Strange. – Markus May 18 '23 at 12:26
3

Suddenly It fixed, maybe the last update from apple through a software update called "Command Line Tools for Xcode". Before I have also tried a fresh OSX installation but the issue has not gone at all.

Check Software Update from system preference.


Thanks to the great community.

Debashish M
  • 193
  • 3
  • 13
1

Try the following:

  1. Clicking on the "Diagnostics" button on the failed preview pane.

  2. Copy the ".pcm" file path. It looks like something similar to "/var/folders/aa/xxxxxxxxxxxxxxxxxxxxxxx/C/clang/ModuleCache/12345ABCDE/MyTest-XXXXXXXXXXXXXX.pcm"

  3. Run the following command to remove the .pcm file in the Terminal app (replace the path using the specific path you copied from the Diagnostics log obtained in the step above:

    rm -rf /var/folders/aa/xxxxxxxxxxxxxxxxxxxxxxx/C/clang/ModuleCache/12345ABCDE/MyTest-XXXXXXXXXXXXXX.pcm

References:

  1. https://support.macincloud.com/support/solutions/articles/8000098646
  2. https://developer.apple.com/forums/thread/696908
macdaemon
  • 9
  • 1
  • maybe this is not the same issue. my xcode preview window message- Cannot preview in this file - Timed out waiting for connection to DTServiceHub after 15.0 seconds. – Debashish M Jan 07 '22 at 08:04
  • 1
    Unreal! For over a week I've been working without a preview. Anything I tried didn't work. Contacted Apple and still sending reports. Now it's working again. – bauerMusic Feb 01 '22 at 15:54
  • This is an easier delete of the whole cache: rm -rf "$(getconf DARWIN_USER_CACHE_DIR)clang/ModuleCache" – sumeet Sep 02 '22 at 15:27
1

For me, it worked when I changed the device to Any iOS Device(Arm 64) for the preview

Ashish Augustine
  • 1,784
  • 4
  • 20
  • 50
0

screenshot

on a Mac with apple silicon chip

  1. CTRL + Click on Xcode app
  2. Get info
  3. Check "open using Rosetta"
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
0

I had the same problem:

No preview with diagnostic : "Cannot preview in this file - Timed out waiting for connection to DTServiceHub after 15.0 seconds".

Tried the solutions found on the internet, without success.

I switched to macOS beta 12.3 and Xcode 13.2. And now there is the preview...

0

The below solution has worked for me:

Running a preview for a project having scenedelegate or appdelegate which worked and then i tried running preview for app protocol style project which was not working earlier.