App crashing when using Firebase Auth, reason: 'Default app has already been configured.'

前端 未结 9 1684
梦如初夏
梦如初夏 2020-12-13 23:34

I\'m building my first iOS application, and I am using Firebase to handle authentication, database, etc. I added a sign up screen and used the following code to create a new

9条回答
  •  情歌与酒
    2020-12-14 00:20

    This is other solution about this issue. 1/ Check in the "AppDelegate.swift" we will see as below

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()
        return true
    }
    

    2/ Remove "FirebaseApp.configure()" from above code to

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
    
        return true
    }
    

    3/ Add below code into "AppDelegate.swift"

    override init() {
        FirebaseApp.configure()
    }
    

    4/ Go to "ViewController.swift" and add the code

        if FirebaseApp.app() == nil {
            FirebaseApp.configure()
        }
    

    5/ Build again and Run it's will work. Thanks!

提交回复
热议问题