SwiftUI / Xcode Error - Updating took more than 5 seconds

In my case the issue was this line in Build settings:

enter image description here

Something I did accidentally changed signing settings in my project. Specifically, "signing identity" was set to "Sign to Run Locally.". For some reasons, SwiftUI Previews don't work then.

Simply deleting this line from build settings (aka setting default value) solved the problem.


Some time, the error displaying is not the real error.

For me it was because i missing : .environmentObject(...)


As of Xcode 12.5.1, the message PreviewUpdateTimedOutError: Updating took more than 5 seconds most likely means that your app crashed and thus updating the preview failed. The real reason for the crash is unfortunately obscured by this useless message (why Apple would do that is beyond me). To get at the real reason, you'll need to:

  • click Diagnostics at the top of the preview next to the useless error message
  • in the next dialog, click Generate Report > Reveal in Finder

This will take a bit. Then Finder will open with a folder highlighted. Open that folder. Inside you'll see a lot of log files and folders.

If your app indeed crashed, you'll see a folder called CrashLogs which contains crash logs for your app, including the error message and stack trace. This should help you resolve the actual error causing the preview to break.

Note that for me, sometimes the CrashLogs were not included in the report even though my app really did crash. Retrying the preview and generating another report fixed this for me. The whole error reporting process seems to be rather unstable for the previews, unfortunately.