使用直接 dart firebase 初始化的 Flutter 在真实设备上仍然会出现错误:无法找到配置文件:'GoogleService-Info.plist'

sst*_*off 6 ios firebase flutter

Flutter 2.8.1 使用 flutterfire - 根据文档,不需要使用 GoogleService-Info.plist 文件。该版本声明它支持直接 dart 初始化。在模拟器上工作正常,但是当在真实的 iOS 设备上运行时 - 从 Android Studio 或 XCode,我收到有关 plist 文件的错误。flutterfire configure 创建一个有效的 firebase_options.dart 文件,main 如下所示:

\n
void main() async {\n  WidgetsFlutterBinding.ensureInitialized();\n  await Firebase.initializeApp(\n    options: DefaultFirebaseOptions.currentPlatform,\n  );\n\n  runApp(const MyApp());\n}\n
Run Code Online (Sandbox Code Playgroud)\n

flutter doctor 的输出:

\n
Doctor summary (to see all details, run flutter doctor -v):\n[\xe2\x9c\x93] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-x64, locale en-US)\n[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)\n    \xe2\x9c\x97 cmdline-tools component is missing\n      Run `path/to/sdkmanager --install "cmdline-tools;latest"`\n      See https://developer.android.com/studio/command-line for more details.\n    \xe2\x9c\x97 Android license status unknown.\n      Run `flutter doctor --android-licenses` to accept the SDK licenses.\n      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.\n[\xe2\x9c\x93] Xcode - develop for iOS and macOS (Xcode 13.2.1)\n[\xe2\x9c\x93] Chrome - develop for the web\n[\xe2\x9c\x93] Android Studio (version 2020.3)\n[\xe2\x9c\x93] VS Code (version 1.63.2)\n[\xe2\x9c\x93] Connected device (3 available)\n
Run Code Online (Sandbox Code Playgroud)\n

小智 0

您是否已在 XCode 中添加 GoogleServices-info.plist 文件?

我的意思是你是否将它从 Finder 拖放到 Android Studio 或 XCode 中。

您需要将其拖放到 XCode 中。

  • 我*没有*这样做过。我知道在过去这是必需的步骤,但根据此处的 flutterfire 文档:https://firebase.flutter.dev/docs/overview#initializing-flutterfire 不再需要此步骤,因为框架现在支持直接 dart初始化。正如我上面提到的,直接 dart 初始化在模拟器中确实有效。我能够连接到 firebase 数据库,执行身份验证活动等。所有这些都无需 plist 文件。但它不适用于真实设备 (6认同)