Hacker News new | ask | show | jobs
by gh123man 1490 days ago
You 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.

1 comments

+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.

one 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