Is it possible to detect when Xcode is building my SwiftUI code for a live preview?
I am working with Core Data managed objects as the data source for SwiftUI views, but they need to be created within a managed object context. At preview time, it's not obvious how to get at the app's persistent container or an existing managed object context. Ideally, I'd prefer to create a temporary store in memory, anyway, both for speed and to not pollute the data used when I run the app.
I'm hoping there is either a compiler flag (like the existing DEBUG one) or something in the process environment that signals that the code is either being built for a preview or is running in preview mode.