SwiftUI Previews: 5s Update Error

Currently, I am developing a quite complex Mac application using Core Data together with SwiftUI. The first challenge I encountered was the SwiftUI preview. I implemented a special preview model with some test data that is assigned to the preview structs of my views as EnvironmentObject. That works fine and I enriched my application step by step.

Well, but suddenly the previews stopped to work. I always got the error message „Updating took more than 5 seconds.“ I suspected one of the recent changes to screw up my work although the completely built applications still worked fine. I walked through my code and certainly found some problematic points but nothing could make the preview show up again.

I ended up switching off part by part of my preview model and suddenly the previews were there again. But I could not find anything wrong in the model. At some point switching one simple statement, certainly not faulty, on or off made the preview show up or not. Interesting…

Then I had the idea to test the project on my new M1 Mac mini, and voilà: the preview is no problem any more. OK, now I’ve got you. The test data in my preview model was just too much. Each preview attempt runs through whole setup process of my preview model which was just too lengthy. Stripping up my test data I have no problem any more displaying the previews.

I could not find any place to increase the 5 seconds limit of SwiftUI previews. If you find it please let me know.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert