Flutter项目iOS模拟器Firebase Storage插件线程错误求助
Flutter Firebase Storage iOS模拟器跨线程报错解决方案(M1设备专属)
解决方案1:锁定兼容M1的插件版本
- 由于M1与M2架构差异,部分新版本
firebase_storage插件在M1设备上存在线程调度问题,可指定稳定兼容版本:- 修改
pubspec.yaml中firebase_storage的版本为^11.2.0 - 执行命令:
flutter pub get - 进入iOS目录,执行:
pod deintegrate && pod install --repo-update
- 修改
解决方案2:开启模拟器Rosetta转译
- 强制模拟器以x86_64架构运行,规避arm64下的线程异常:
- 打开Xcode,点击菜单栏
Product->Destination->Destination Architectures->Show Rosetta Destinations - 选择带「Rosetta」标识的模拟器重新运行项目
- 打开Xcode,点击菜单栏
解决方案3:修改Podfile架构配置
- 在iOS项目的Podfile中添加架构约束,确保插件以兼容模式编译:
- 打开
ios/Podfile,在post_install代码块中添加架构配置:post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) # 添加以下两行配置 target.build_configurations.each do |config| config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'x86_64' end end end - 执行命令:
pod install
- 打开
解决方案4:重置Firebase配置文件
- 删除iOS项目中旧的
GoogleService-Info.plist,从Firebase控制台重新下载与项目包名完全匹配的配置文件,替换后重新运行项目
内容的提问来源于stack exchange,提问作者Nisa Sivritepe
相关产品推荐
相关产品推荐

