3 ms·
Has anyone gotten SwiftUI previews to work at all with a project that has more than 20 files or some dependencies? My project utilizes Firebase as the backend
by akmarinov 4y ago
Has anyone gotten SwiftUI previews to work at all with a project that has more than 20 files or some dependencies?
My project utilizes Firebase as the backend and as soon as you add that dependency - SwiftUI previews never compile, due to build time outs.
- gh123man 4y agoYou are probably pulling firebase into your preview code somewhere. You should structure your previews to depend on mock implementations of your model (or mock data). It will make the previews much faster and more reliable. My app also uses firebase and SwiftUI with hundreds of files (views, view models, and more) with no problems.
- emllnd 4y ago+1 on this Got working SwiftUI previews on a 50-100k LOC project with many big libs as dependencies, must be hundreds of files but havent counted. SwiftUI code is gaining share of the total UI code, probably around 20-30% now Mock data is a must. Need to be mindful of the preview build (+ preview simulator startup) time too, sometimes it will timeout but just building again (now warmer) will make it work Had some initial issues around processor arch (Intel vs M1/arm), think I’m still running XCode under rosetta otherwise it wouldnt work.
- andrekandre 4y agoone other solution is to build a sub project that links to a subset of minimum dependencies needed for ui development and build your swiftui stuff there... it will be lightning fast compared to large xcode project... and it might even be better architecturally too, since you'd have to factor out lower level logic (view models or whatever) anyways
- tarentel 4y agoNope. We have a fairly complicated project, 20+ frameworks, the preview feature doesn't work. We're not using firebase either.
- emehex 4y agoAre you using MVVM and mocking out your ViewModels?
- akmarinov 4y agoIt’s literally the Firebase libraries as it’s the backend and a couple of views.
- bryansum 4y agoYes, I recently built an entire app with 70+ frameworks that works fine in Previews. The key is to isolate dependencies into their own modules, and also split those into interface / live implementation modules if needed if the live impl causes preview crashes. See https://www.pointfree.co/episodes/ep171-modularization-part-1 https://www.pointfree.co/episodes/ep171-modularization-part-...
- mamcx 4y ago> Has anyone gotten SwiftUI previews to work ... has more than 1 Not JetPack or SwiftUI works for even a simple view!. Is incredible slow and still not true to how it will show up! I miss the way Delphi do it...