无法使用Flutter + Firebase打开iOS应用

问题描述 投票:0回答:1

我正在将Firebase设置为Flutter应用。我完成了Android的设置,并在Firebase Analytics仪表板上看到了流量。但是,iOS版本崩溃并显示以下消息。你能给我任何想法吗?

  1. 我从Firebase UI下载了GoogleService-Info.plist,并使用mv命令将其移至ios/Runnder目录。
  2. 我将pod 'Firebase/Analytics'添加到ios/Podfile并运行pod install。 (这时,我通过Android Studio打开了iOS模拟器,并确认该应用已正常运行。)enter image description here
  3. 我在ios.Runnder.AppDelegate.swift中添加了两行。
import UIKit
import Flutter
import Firebase // Added!!!

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    FirebaseApp.configure() // Added!!!
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
  1. 然后我尝试再次在iOS模拟器上运行该应用,并且此错误消息在Android Studio上显示。
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Running Xcode build...
Xcode build done.                                           39.5s
    path: satisfied (Path is satisfied), interface: en0
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010cc8527e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x000000010caf2b20 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010cc850bc +[NSException raise:format:] + 188
    3   Runner                              0x000000010991c9ea +[FIRApp configure] + 138
    4   Runner                              0x0000000109917ca4 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtF + 212
    5   Runner                              0x0000000109917ff4 $s6Runner11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 21<…>
ios firebase flutter
1个回答
0
投票

您的问题是您不能简单地将GoogleService-Info.plist移动到ios / Runner目录中,必须将其添加到xcode项目中才能被识别。为此,请打开应用程序的xcode项目,右键单击Runner目录,然后选择“将文件添加到“ Runner”,如下所示。然后导航到GoogleService-Info.plist的下载位置,然后选择它以将其添加到项目中。

Screenshot of xcode Add Files to Runner

© www.soinside.com 2019 - 2024. All rights reserved.