【发布时间】:2019-09-25 12:45:20
【问题描述】:
在我的项目中,我对具有不同配置(生产/暂存/质量检查)的同一个应用程序有不同的目标。正如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 添加到您的应用”下的第 4 步操作:firebase.google.com/docs/ios/setup#prerequisites
-
您的意思是“将 Firebase SDK 添加到您的应用”吗?我已经在项目中添加了
'Firebase/Core'。此外,当使用单个GoogleService-Info.plist时,一切正常(我的应用程序已经投入生产并且 Analytics 正在运行)。 -
你检查过每个配置吗?它们的行为是否完全相同?根据该错误消息,FirebaseOptions 似乎没有正确设置(特别是因为您不再使用默认文件名)。
-
我从 Firebase 控制台下载了配置文件。同样在调试器中,如果我在将
options传递给FirebaseApp.configure之前检查options.googleAppID的值,我会得到正确的值。 -
我遇到了类似的问题,所以我保留了原始文件名,我将文件移动到文件夹并根据目标设置目标成员资格。你试过了吗?
标签: ios firebase firebase-analytics