Problems with Firebase and SwiftUI Live Previews

Try Disable Code Coverage for the scheme.

This worked for me.

On Xcode 11.3 I've been able to get SwiftUI Previews building by simply disabling Code Coverage gathering for my scheme. The above solutions weren't working as I was still getting "failedToBuildDylib" errors for Firebase. In fact, the above fixes don't seem to be necessary at all, at least on my case. Hope this helps someone.

Credits to: https://twitter.com/dannypier/status/1190312160557068293


For now I have to temporarily disable Firebase (and GoogleSignIn) to work with SwiftUI's Live Previews.

In my case I use Cocoapods, so I comment out the libraries from my Podfile:

#  pod 'Firebase/Analytics'
#  pod 'Firebase/Crashlytics'
#  pod 'Firebase/Messaging'
#  pod 'GoogleSignIn'

Then $ pod install to temporarily remove them.

And finally use #if canImport(Firebase) (and #if canImport(GoogleSignIn)) preprocessor macros where needed.

#if canImport(Firebase)
import Firebase
#endif
#if canImport(GoogleSignIn)
import GoogleSignIn
#endif

// ...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
    // ...

    #if canImport(Firebase)
    FirebaseApp.configure()
    #endif

Not optimal, but until Xcode 12 fixes it or Google updates its frameworks no other way around it.