[英]Flutter App crashes on iOS on start. Xcode error "unrecognized Selector"
使用 flutter 构建的应用程序现在拒绝在 iOS 上运行,但我一个月前工作过。 该应用程序构建但打开时(模拟器和 iPhone)它在白屏半秒后崩溃。
该错误似乎出现在 AppDelegate.swift 文件中。 Xcode 在
“@obj class AppDelegate:FlutterAppDelegate {”行:线程 1:异常:“-[__NSArrayM boolValue]:无法识别的选择器发送到实例 0x60000099a430”
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
完整的 xCode 堆栈:
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23e3de6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff512a19b2 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23e5eb94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff23e4286c ___forwarding___ + 1436
4 CoreFoundation 0x00007fff23e44b58 _CF_forwarding_prep_0 + 120
5 Flutter 0x000000010f99ab9a _ZN7flutter32IsIosEmbeddedViewsPreviewEnabledEv + 130
6 Flutter 0x000000010f977839 -[FlutterEngine createShell:libraryURI:] + 829
7 Flutter 0x000000010f98b2fd -[FlutterViewController initWithProject:nibName:bundle:] + 287
8 UIKitCore 0x00007fff48fc75a7 -[UIClassSwapper initWithCoder:] + 2427
9 UIFoundation 0x00007fff487ee274 UINibDecoderDecodeObjectForValue + 743
10 UIFoundation 0x00007fff487edf80 -[UINibDecoder decodeObjectForKey:] + 251
11 UIKitCore 0x00007fff48fcb83a -[UIRuntimeConnection initWithCoder:] + 125
12 UIFoundation 0x00007fff487ee274 UINibDecoderDecodeObjectForValue + 743
13 UIFoundation 0x00007fff487ee518 UINibDecoderDecodeObjectForValue + 1419
14 UIFoundation 0x00007fff487edf80 -[UINibDecoder decodeObjectForKey:] + 251
15 UIKitCore 0x00007fff48fc6675 -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 450
16 UIKitCore 0x00007fff48fc9388 -[UINib instantiateWithOwner:options:] + 1120
17 UIKitCore 0x00007fff494eb817 -[UIStoryboard __reallyInstantiateViewControllerWithIdentifier:creator:storyboardSegueTemplate:sender:] + 279
18 UIKitCore 0x00007fff494eb6c2 -[UIStoryboard _instantiateViewControllerWithIdentifier:creator:storyboardSegueTemplate:sender:] + 97
19 UIKitCore 0x00007fff49371b05 -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 167
20 UIKitCore 0x00007fff4937209a -[UIApplication _loadMainInterfaceFile] + 274
21 UIKitCore 0x00007fff49370a6b -[UIApplication _runWithMainScene:transitionContext:completion:] + 964
22 UIKitCore 0x00007fff48a7912d -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
23 UIKitCore 0x00007fff48f84b61 _UIScenePerformActionsWithLifecycleActionMask + 83
24 UIKitCore 0x00007fff48a79c3f __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
25 UIKitCore 0x00007fff48a7964e -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 296
26 UIKitCore 0x00007fff48a79a6c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 818
27 UIKitCore 0x00007fff48a79301 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345
28 UIKitCore 0x00007fff48a7d8f2 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 178
29 UIKitCore 0x00007fff48e9ac4d +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 852
30 UIKitCore 0x00007fff48fa32be _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240
31 UIKitCore 0x00007fff48a7d60d __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 153
32 UIKitCore 0x00007fff48fa31c1 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 84
33 UIKitCore 0x00007fff48a7d47b -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 381
34 UIKitCore 0x00007fff488d1e78 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 657
35 UIKitCore 0x00007fff488d0a37 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253
36 UIKitCore 0x00007fff488d1ba2 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 210
37 UIKitCore 0x00007fff4936f0b9 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 512
38 UIKitCore 0x00007fff48ec177c -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
39 FrontBoardServices 0x00007fff36d03d2e -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 419
40 FrontBoardServices 0x00007fff36d29dc1 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154 + 102
41 FrontBoardServices 0x00007fff36d0e757 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 220
42 FrontBoardServices 0x00007fff36d29a52 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke + 355
43 libdispatch.dylib 0x00000001123c0e8e _dispatch_client_callout + 8
44 libdispatch.dylib 0x00000001123c3da2 _dispatch_block_invoke_direct + 300
45 FrontBoardServices 0x00007fff36d4f6e9 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
46 FrontBoardServices 0x00007fff36d4f3d7 -[FBSSerialQueue _queue_performNextIfPossible] + 441
47 FrontBoardServices 0x00007fff36d4f8e6 -[FBSSerialQueue _performNextFromRunLoopSource] + 22
48 CoreFoundation 0x00007fff23da1c91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
49 CoreFoundation 0x00007fff23da1bbc __CFRunLoopDoSource0 + 76
50 CoreFoundation 0x00007fff23da1394 __CFRunLoopDoSources0 + 180
51 CoreFoundation 0x00007fff23d9bf8e __CFRunLoopRun + 974
52 CoreFoundation 0x00007fff23d9b8a4 CFRunLoopRunSpecific + 404
53 GraphicsServices 0x00007fff38c05bbe GSEventRunModal + 139
54 UIKitCore 0x00007fff49372964 UIApplicationMain + 1605
55 Runner 0x000000010d5c1d1b main + 75
56 libdyld.dylib 0x00007fff5211c1fd start + 1
57 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
我曾尝试清理 Xcode(产品 -> 清理构建文件夹)、颤动(颤动清理)。 错误在于没有将所有与 iOS 相关的文件推送到 GitHub。 Podfile、Podfile.lock 没有被推送。 当我尝试使用较新的 iOS 文件重建它时,正在运行的旧应用程序版本现在已损坏。
由于我对 Xcode 没有太多经验,因此我很难理解错误。 感谢您的帮助!
编辑:符号断点堆栈:
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
* frame #0: 0x00007fff23e5eb10 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:]
frame #1: 0x00007fff23e4286c CoreFoundation`___forwarding___ + 1436
frame #2: 0x00007fff23e44b58 CoreFoundation`__forwarding_prep_0___ + 120
frame #3: 0x000000010c41db9a Flutter`flutter::IsIosEmbeddedViewsPreviewEnabled() + 130
frame #4: 0x000000010c3fa839 Flutter`-[FlutterEngine createShell:libraryURI:] + 829
frame #5: 0x000000010c40e2fd Flutter`-[FlutterViewController initWithProject:nibName:bundle:] + 287
frame #6: 0x00007fff48fc75a7 UIKitCore`-[UIClassSwapper initWithCoder:] + 2427
frame #7: 0x00007fff487ee274 UIFoundation`UINibDecoderDecodeObjectForValue + 743
frame #8: 0x00007fff487edf80 UIFoundation`-[UINibDecoder decodeObjectForKey:] + 251
frame #9: 0x00007fff48fcb83a UIKitCore`-[UIRuntimeConnection initWithCoder:] + 125
frame #10: 0x00007fff487ee274 UIFoundation`UINibDecoderDecodeObjectForValue + 743
frame #11: 0x00007fff487ee518 UIFoundation`UINibDecoderDecodeObjectForValue + 1419
frame #12: 0x00007fff487edf80 UIFoundation`-[UINibDecoder decodeObjectForKey:] + 251
frame #13: 0x00007fff48fc6675 UIKitCore`-[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 450
frame #14: 0x00007fff48fc9388 UIKitCore`-[UINib instantiateWithOwner:options:] + 1120
frame #15: 0x00007fff494eb817 UIKitCore`-[UIStoryboard __reallyInstantiateViewControllerWithIdentifier:creator:storyboardSegueTemplate:sender:] + 279
frame #16: 0x00007fff494eb6c2 UIKitCore`-[UIStoryboard _instantiateViewControllerWithIdentifier:creator:storyboardSegueTemplate:sender:] + 97
frame #17: 0x00007fff49371b05 UIKitCore`-[UIApplication _loadMainStoryboardFileNamed:bundle:] + 167
frame #18: 0x00007fff4937209a UIKitCore`-[UIApplication _loadMainInterfaceFile] + 274
frame #19: 0x00007fff49370a6b UIKitCore`-[UIApplication _runWithMainScene:transitionContext:completion:] + 964
frame #20: 0x00007fff48a7912d UIKitCore`-[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
frame #21: 0x00007fff48f84b61 UIKitCore`_UIScenePerformActionsWithLifecycleActionMask + 83
frame #22: 0x00007fff48a79c3f UIKitCore`__101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
frame #23: 0x00007fff48a7964e UIKitCore`-[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 296
frame #24: 0x00007fff48a79a6c UIKitCore`-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 818
frame #25: 0x00007fff48a79301 UIKitCore`-[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345
frame #26: 0x00007fff48a7d8f2 UIKitCore`__186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 178
frame #27: 0x00007fff48e9ac4d UIKitCore`+[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 852
frame #28: 0x00007fff48fa32be UIKitCore`_UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240
frame #29: 0x00007fff48a7d60d UIKitCore`__186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 153
frame #30: 0x00007fff48fa31c1 UIKitCore`_UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 84
frame #31: 0x00007fff48a7d47b UIKitCore`-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 381
frame #32: 0x00007fff488d1e78 UIKitCore`__64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 657
frame #33: 0x00007fff488d0a37 UIKitCore`-[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253
frame #34: 0x00007fff488d1ba2 UIKitCore`-[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 210
frame #35: 0x00007fff4936f0b9 UIKitCore`-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 512
frame #36: 0x00007fff48ec177c UIKitCore`-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
frame #37: 0x00007fff36d03d2e FrontBoardServices`-[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 419
frame #38: 0x00007fff36d29dc1 FrontBoardServices`__86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154 + 102
frame #39: 0x00007fff36d0e757 FrontBoardServices`-[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 220
frame #40: 0x00007fff36d29a52 FrontBoardServices`__86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke + 355
frame #41: 0x0000000110d28e8e libdispatch.dylib`_dispatch_client_callout + 8
frame #42: 0x0000000110d2bda2 libdispatch.dylib`_dispatch_block_invoke_direct + 300
frame #43: 0x00007fff36d4f6e9 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
frame #44: 0x00007fff36d4f3d7 FrontBoardServices`-[FBSSerialQueue _queue_performNextIfPossible] + 441
frame #45: 0x00007fff36d4f8e6 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 22
frame #46: 0x00007fff23da1c91 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #47: 0x00007fff23da1bbc CoreFoundation`__CFRunLoopDoSource0 + 76
frame #48: 0x00007fff23da1394 CoreFoundation`__CFRunLoopDoSources0 + 180
frame #49: 0x00007fff23d9bf8e CoreFoundation`__CFRunLoopRun + 974
frame #50: 0x00007fff23d9b8a4 CoreFoundation`CFRunLoopRunSpecific + 404
frame #51: 0x00007fff38c05bbe GraphicsServices`GSEventRunModal + 139
frame #52: 0x00007fff49372964 UIKitCore`UIApplicationMain + 1605
frame #53: 0x000000010a06a00b Runner`main at AppDelegate.swift:5:13
frame #54: 0x00007fff5211c1fd libdyld.dylib`start + 1
对我来说,似乎 IsIosEmbeddedViewsPreviewEnabled() 破坏了构建。 知道如何从这里继续吗?
应用程序再次在 iOS 上运行。 有帮助的是:
flutter create myProjectPath
重新创建/修复的文件:
iOS/Podfile ios/Podfile.lock ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings ios/Runner/Info.plist
希望这可能会在将来对某人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.