Xcode 13.2.1 Preview Not Working but Simulator Works

9.8k views Asked by At

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

8

There are 8 answers

0
Debashish M On BEST ANSWER

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.

0
Aarin Bothra On

I was having the same issue; it seems that creating a new SwiftUI file refreshes the preview and then it begins to work again.

0
Mohanish Mayank On

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.

3
Ramy Rizkalla On

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

enter image description here

3
macdaemon On

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
0
Артур Рыжих On

screenshot

on a Mac with apple silicon chip

  1. CTRL + Click on Xcode app
  2. Get info
  3. Check "open using Rosetta"
0
fred milloh On

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

1
Ashish Augustine On

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