ios - 使用 FirebaseApp.configure 时无法找到配置文件 GoogleService-Info.plist(选项 :)

标签 ios firebase firebase-analytics

在我的项目中,我对具有不同配置(生产/暂存/质量检查)的同一应用程序有不同的目标。正如 Firebase docs 所建议的我为每个目标添加了一个 plist 文件,并通过以下方式传递正确的配置文件来初始化 FirebaseApp:

let configPath = Bundle.main.path(forResource: NAME_OF_PLIST_FOR_CURRENT_TARGET ofType: ".plist")!
let options = FirebaseOptions(contentsOfFile: configPath)!
FirebaseApp.configure(options: options)

我还按照文档 here 中的建议从项目中删除了 GoogleService-Info.plist 文件。以确保可靠的分析报告。

当我在控制台中运行应用程序时,我会看到这些消息。

[Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'.
[Firebase/Analytics][I-ACS020006] Google App ID from GoogleService-Info.plist is empty. Please, define GOOGLE_APP_ID in GoogleService-Info.plist for Analytics to work reliably. See
[Firebase/Analytics][I-ACS025020] Analytics requires Google App ID from GoogleService-Info.plist. Your data may be lost. Google App ID has been changed. Original, new ID: (nil), MYAPPID 

我做错了什么吗?此配置是否会导致分析丢失? (如控制台消息所示)

最佳答案

经过多次尝试,尽管控制台中出现错误消息,Firebase 似乎配置正确。

尽管如此,我还是决定采用 @Micgal 提出的解决方案,从而在单独的文件系统目录中拥有多个名为 GoogleService-Info.plist 的文件,并将每个文件添加到相应的目标中。然后,我可以使用 FirebaseApp.configure() 初始化 Firebase,它按预期工作,不会生成错误消息。

关于ios - 使用 FirebaseApp.configure 时无法找到配置文件 GoogleService-Info.plist(选项 :),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58098740/

相关文章:

objective-c - 如何自动弹出到上一个viewController?

ios - 将区号与电话号码分开 - iOS

arrays - 移动 Firebase 数组中的项目

firebase - 允许 Firebase Analytics 域名而不允许其他 Google 服务

android - Firebase 分析事件不显示值(value)

ios - 当 View 当前不可见时更改 Collection View 的滚动位置

ios - Swift4 - 我第一次无法显示 CollectionView "Unable to simultaneously satisfy constraints"

html - 为什么YouTube加载速度如此之快,每次移动进度时,我都会尝试使用flutter代码多次,

node.js - 创建多个 firebase-admin 实例

firebase - 删除现有项目后无法创建 Firebase (Google) 项目