4
votes

I created a new SwiftUI project but the default code will not load in the live preview window. I get the following error every time: "Cannot preview in this file - Update failed". I am running Xcode 11.4 on Catalina 10.15.4

Image of the error in Xcode Image of the error in Xcode

Image of the diagnostics report Image of the diagnostics report

Here is a list of the things that I have tried so far:

1) Restarted Xcode and my computer

2) Cleaned the build folder of the project

3) Deleted the build folder and reran the project

4) Changed the simulator device (I've tried Generic iOS device, iPhone 11, 11 pro max, etc.)

5) Changed the project location to desktop

Any help would be much appreciated!

1
Try to update your Xcode. - sfung3
Which Xcode version? - Austin Conlon
same here with xcode 13.4 - Emre Değirmenci
same here with xcode 11.5 - Spencer Reid

1 Answers

0
votes

I had a similar issue, but in my case diagnostics showed: RemoteHumanReadableError

My fix was to quit Xcode (close window and quit from menu or use CMD+Q).

Delete contents of:

/Users/$(whoami)/Library/Developer/Xcode/DerivedData/

With something like this:

rm -rf /Users/$(whoami)/Library/Developer/Xcode/DerivedData/*

NOTE: System may ask you for confirmation, so you have to answer y and tap enter (always use rm -rf with caution!).

Then start Xcode again and open project - it took little longer to load but worked fine without issue.

I just hope this helps solving OP issue as well as other simillar issues with SwiftUI preview stupid errors not related to code.