Created
May 25, 2021 07:19
-
-
Save shawnkoh/212758eceb010b4caf840a79c8c22598 to your computer and use it in GitHub Desktop.
How to check if SwiftUI previews are running
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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