fra*_*iga 5 ios firebase firebase-analytics
在我的项目中,我对具有不同配置(生产/暂存/质量检查)的同一应用程序有不同的目标。根据Firebase 文档的建议,我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)
Run Code Online (Sandbox Code Playgroud)
我还按照此处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
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?此配置是否会导致分析丢失?(如控制台消息所示)
我使用命令运行 flutter cli 将 Firebase 添加到我的项目中flutterfire configure。这将添加GoogleService_Info.plist到我的项目中,但没有在.xcworkspace文件中注册该文件。
所以我必须右键单击RunnerXcode 中的 -folder,选择Add Files to "Runner"...,然后选择文件GoogleService_Info.plist
经过多次尝试后,尽管控制台中出现错误消息,Firebase 似乎已正确配置。
尽管如此,我还是决定采用 @Micgal 提出的解决方案,从而在单独的文件系统目录中命名多个文件GoogleService-Info.plist,并将每个文件添加到相应的目标中。然后,我可以初始化 Firebase,使其FirebaseApp.configure()按预期工作,而不会生成错误消息。
| 归档时间: |
|
| 查看次数: |
24455 次 |
| 最近记录: |