Skip to content

Instantly share code, notes, and snippets.

@shawnkoh
Created May 25, 2021 07:19
Show Gist options
  • Save shawnkoh/212758eceb010b4caf840a79c8c22598 to your computer and use it in GitHub Desktop.
Save shawnkoh/212758eceb010b4caf840a79c8c22598 to your computer and use it in GitHub Desktop.
How to check if SwiftUI previews are running
import SwiftUI
@main
struct ExampleApp: App {
init() {
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
// SwiftUI Preview is running.
// Do nothing.
} else {
FirebaseApp.configure()
let settings = FirestoreSettings()
Firestore.firestore().settings = settings
}
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment