ios – 在新的Firebase中,如何在xcode中使用多个配置文件?

嗨,我正在玩新的firebase iOS SDK,在我的项目中,我只有一个目标,我创建了两个配置,Debug和Release,具有不同的bundler标识符,但是似乎从firebase下载的配置文件只支持一个bundle标识符.

所以任何人都知道如何在多个包标识符xcode项目中使用firebase?

谢谢!

解决方法

我的第一个尝试没有解决问题:

我将第二个GoogleService-Info.json重命名为其他内容,并使用以下代码从AppDelegate配置Firebase.

// Swift code
#if STAGING
    let firebasePlistFileName = "GoogleService-Staging-Info"
#else
    let firebasePlistFileName = "GoogleService-Info"
#endif
let firbaseOptions = FIROptions(contentsOfFile: NSBundle.mainBundle().pathForResource(firebasePlistFileName,ofType: "plist"))
FIRApp.configureWithOptions(firbaseOptions)

如果我运行Staging目标,我将收到Firebase关于“无法找到配置文件:”GoogleService-Info.plist“的投诉.但是,它说“Firebase Analytics v.3300000已启动”.

当我在Firebase仪表板上检查时,生产和分段应用程序都会记录传入的用户事件.

上面提到的configureWithOptions方法没有记录在Firebase文档中,我通过检查它的源代码来计算出来.我不知道这可能是什么不利的.我很乐意听到其他方法.

更新了一个更容易的解决方案:

1. keep the same names for both GoogleService-Info.plist
2. put one GoogleService-Info.plist inside a subfolder,say "staging"
3. add references to both files in Xcode,while link them to corresponding targets
4. just use FIRApp.configure() in your AppDelegate,done

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...