Objective C
has preprocessor, Swift
has compilation conditions that allows to use different code for different environments, for example for debug or release build:
#if DEBUG
print("debug message")
doDebugAction()
#else
doReleaseAction()
#endif
Can I add code that compiles only for SwiftUI preview? Something like:
#if targetEnvironment(swiftUIPreview)
static func mock() -> SomeStruct {
// fill random data
}
#endif