iOS 上的 Flutter 插件抛出错误“线程 1:EXC_BAD_ACCESS”
Posted
技术标签:
【中文标题】iOS 上的 Flutter 插件抛出错误“线程 1:EXC_BAD_ACCESS”【英文标题】:Flutter Plugin Throwing Error "Thread 1: EXC_BAD_ACCESS" on iOS 【发布时间】:2021-05-19 12:38:42 【问题描述】:我一直在尝试在我的 Flutter 应用程序中使用位于 https://pub.dev/packages/livechatt 的插件“livechat”。让它在 android 版本中运行没有问题,但在 ios 上,它每次都以相同的方式失败。
我在pubspec.yaml
中导入了这个包,就像我使用其他插件一样。从 Android Studio 在 iOS 模拟器中运行应用程序时,构建成功,但应用程序在启动后立即崩溃。从 Xcode 运行应用程序时,构建成功,但应用程序在启动启动屏幕上冻结。
注意:就目前而言,该插件在 iOS 中的依赖项确实存在错误,因此那些测试它的人需要在livechatt.podspec
中将目标操作系统从 iOS 9.0 更改为 iOS 11.0,然后运行 @ 987654324@在项目的iOS目录中同步更改
Xcode 然后显示以下错误:
错误 4
Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee7ce5ff8)
in ios\.symlinks\plugins\livechatt\ios\classes\LiveChatPlugin.m
#import "LivechatPlugin.h"
#if __has_include(<livechat/livechat-Swift.h>)
#import <livechat/livechat-Swift.h>
#else
// Support project import fallback if the generated compatibility header
// is not copied when this plugin is created as a library.
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
#import "livechat-Swift.h"
#endif
@implementation LivechatPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar <-- ERROR HERE
[LivechatPlugin registerWithRegistrar:registrar];
@end
错误 5-1000、173400-174359
Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee7ce5ff8)
in ios\.symlinks\plugins\livechatt\ios\classes\LiveChatPlugin.m
#import "LivechatPlugin.h"
#if __has_include(<livechat/livechat-Swift.h>)
#import <livechat/livechat-Swift.h>
#else
// Support project import fallback if the generated compatibility header
// is not copied when this plugin is created as a library.
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
#import "livechat-Swift.h"
#endif
@implementation LivechatPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar
[LivechatPlugin registerWithRegistrar:registrar]; <-- ERROR HERE
@end
Runner\GeneratedPluginRegistrant.m
中的错误 174360 Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffee7ce5ff8)
/* previous code ommitted for brevity */
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry
[AppAvailability registerWithRegistrar:[registry registrarForPlugin:@"AppAvailability"]];
[FlutterLocalNotificationsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterLocalNotificationsPlugin"]];
[FLTGoogleMapsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTGoogleMapsPlugin"]];
[LivechatPlugin registerWithRegistrar:[registry registrarForPlugin:@"LivechatPlugin"]]; <-- ERROR HERE
[LocationPlugin registerWithRegistrar:[registry registrarForPlugin:@"LocationPlugin"]];
[MsalMobilePlugin registerWithRegistrar:[registry registrarForPlugin:@"MsalMobilePlugin"]];
[FLTPathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPathProviderPlugin"]];
[FLTSharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTSharedPreferencesPlugin"]];
[SqflitePlugin registerWithRegistrar:[registry registrarForPlugin:@"SqflitePlugin"]];
[FLTURLLauncherPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTURLLauncherPlugin"]];
[FLTWebViewFlutterPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTWebViewFlutterPlugin"]];
@end
我能否帮助诊断在这些地方引发此错误的原因,以及为什么它只影响 livechat 插件?谢谢!
【问题讨论】:
【参考方案1】:我是上述包的作者。该问题已在最新版本中得到修复。请更新您的 pubspec.yaml 中的包
dependencies:
livechatt: "^1.1.0"
【讨论】:
以上是关于iOS 上的 Flutter 插件抛出错误“线程 1:EXC_BAD_ACCESS”的主要内容,如果未能解决你的问题,请参考以下文章
如何设置 flutter_socket_io 插件以在 iOS 上工作
Flutter 中的共享首选项错误 - Mac 上的 iOS