Has Swift compilation condition for SwiftUI preview environment?

Solution 1:

Unfortunately it doesn't exist any compilation condition afaik, but you can use ProcessInfo:

ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"