Flutter Firebase在iOS上崩溃

laik7k3q  于 2023-11-21  发布在  Flutter
关注(0)|答案(1)|浏览(190)

我有一个Flutter应用程序,使用Firebase作为后端。我试图根据本文使用Firebase开发和生产项目为我的应用程序创建开发和生产环境:https://kmtsandeepanie.medium.com/set-up-multiple-firebase-environments-in-flutter-9f88bc284454
一切似乎都是正确的,应用程序构建在iOS上,除了它在启动时崩溃,而在Android Studio的调试控制台中没有错误:

Launching lib/main.dart on iPhone 14 Pro Max in debug mode...
Running pod install...                                             13.5s
Upgrading Pods-Runner-frameworks.sh
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         9.8s
Xcode build done.                                           39.8s
[VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend.
Lost connection to device.
Syncing files to device iPhone 14 Pro Max...                       200ms

字符串
崩溃后,我得到以下堆栈跟踪:

Last Exception Backtrace:

0   CoreFoundation                         0x180437324 __exceptionPreprocess + 160    
1   libobjc.A.dylib                        0x180051274 objc_exception_throw + 56   
2   CoreFoundation                         0x180437240 -[NSException initWithCoder:] + 0    
3   FirebaseCore                           0x1034d06d8 +[FIRApp configureWithName:options:] + 284 (FIRApp.m:172)    
4   Runner                                 0x102fac0d4 -[FLTFirebaseCorePlugin initializeAppAppName:initializeAppRequest:completion:] + 1320   
5   Runner                                 0x102fae5b4 __FirebaseCoreHostApiSetup_block_invoke + 192    
6   Flutter                                0x10b8a2b0c __48-[FlutterBasicMessageChannel setMessageHandler:]_block_invoke + 168    
7   Flutter                                0x10b2cc234 invocation function for block in flutter::PlatformMessageHandlerIos::HandlePlatformMessage(std::_LIBCPP_ABI_NAMESPACE::unique_ptr<flutter::PlatformMessage, std::_LIBCPP_ABI_NAMESPACE::default_delete<flutter::PlatformMessage>>) + 108


在切换到开发/生产环境之前,我已经成功地实现了Firebase。你知道那个错误是什么吗?
提前感谢!

gz5pxeao

gz5pxeao1#

发现问题:
我在“initializeApp”上设置了“name”属性:

if (env == 'prod') {
    await Firebase.initializeApp(
      name: 'com.example.prod',
      options: ProdFirebaseOptions.currentPlatform,
    );
} else {
    await Firebase.initializeApp(
      name: 'com.example.dev',
      options: DefaultFirebaseOptions.currentPlatform,
    );
}

字符串
这在Android上运行良好,但在某些情况下似乎会崩溃iOS。

相关问题