In new Firebase, how to use multiple config file in xcode?

后端 未结 9 1468
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 09:14

Hey I am playing with the new firebase iOS SDK, in my project, I have only one target, I created two configurations, Debug and Release, with different bundler identifier, but se

9条回答
  •  一向
    一向 (楼主)
    2021-01-30 09:35

    Firebase includes official documentation for how to do this now. I used this method in my app and it works great.

    More specifically, I defined a custom Swift flag "BUILD_TYPE" in XCode and for each scheme, I define a unique value for that flag. Then, in my AppDelegate, I tell Firebase what GoogleService-___.plist file to load at runtime by this Swift flag value:

        let filePath = Bundle.main.path(forResource: "GoogleService-" + Bundle.main.infoDictionary!["BUILD_FLAVOR"] as! String, ofType: "plist")
        guard let fileopts = FirebaseOptions.init(contentsOfFile: filePath!) else {
            fatalError("Couldn't load config file")
        }
        FirebaseApp.configure(options: fileopts)
    

提交回复
热议问题