Is there any way to speed up SwiftUI Previews?

We have a fairly large app with dozens of dependencies.

SwiftUI Previews take ages to build, even though they are only using a fraction of our code.

I managed to speed them up a bit by disabling most of my custom build phases. But they are still super slow due to how long it takes to build things like Firebase.

Anyone have any ideas here? Is there a way to ensure that previews are only compiling the files that they need to work?

Replies

An Xcode Previews talk at WWDC has some helpful advice regarding breaking your project up in to smaller modules and moving your UI pieces to be in a leaf-node of your dependency graph. This will then enable previews to be rendered without having to build your entire app..