SwiftUI Preview: FailedToConnectToDTServiceHubError: Cannot connect to iPhone

Xcode 12.4
macOS Catalina 10.15.7

Every time I try to use SwfitUI previews it fails with the following message:

Code Block
FailedToConnectToDTServiceHubError: Cannot connect to iPhone 12

Diagnostics:
Code Block
FailedToConnectToDTServiceHubError: Cannot connect to iPhone 12
Try disconnecting and reconnecting the device.
iPhone 12 {}

I've tried:
  • Deleting Derived Data

  • Choosing other simulators

  • Running iOS 13 SDK using Xcode 11 (latest version)

  • Changing SDK to previous version

  • Creating a completely new SwiftUI project

  • Deleting all simulators and reinstalling them through Xcode

  • Resetting the currently opened simulator with Device -> Erase all Content and settings

None of the above worked.
Any advice? Thanks.
Hi

I'm experiencing the exact problem.

I even tried to restart my mac with no luck.
I got a similar issue. The error message is: Cannot preview in this file -- Cannot connect to iPhone 12 Pro Max. Clicking on the info button shows:

Try disconnecting and reconnecting the device.
Hi, I got the exact same problem like described above by claps lock. Could any of you solve this issue?
Best regards
My solution to this issue was to update the OS to Big Sur and update XCode to 12.5, after that preview started to work.

I'm new to iOS development, first learned Swift language, and then started the official Apple SwiftUI tutorial.
It's pretty annoying to bump into this issue (and some other) straight away.
This issue could be solved by updating to Big Sur

The target device also needs to be in Developer Mode.

  • In iOS Settings > Privacy & Security > Developer Mode
  • May need to restart the device
  • Xcode will install an app on the device called "Xcode Previews"
  • Xcode will rebuild your project target app for the preview (this will take a little time)
SwiftUI Preview: FailedToConnectToDTServiceHubError: Cannot connect to iPhone
 
 
Q