Search code examples
iosswiftuikitcarplay

I am integrating CarPlay with an iOS app, but it gets crashed when I make an api request and other cases


I am integrating CarPlay into an iOS app, for Quick food ordering, but when I make an API request, and it returns success, the app gets crashed, as well when there's a loader presented in the iOS app itself.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTemplateApplicationScene windows]: unrecognized selector sent to instance 0x172371180' *** First throw call stack: ( 0 CoreFoundation 0x0000000116f348a8 __exceptionPreprocess + 172 1 libobjc.A.dylib
0x000000010a8c809c objc_exception_throw + 56 2 CoreFoundation
0x0000000116f496f8 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0 3 UIKitCore
0x000000012d8ef3d4 -[UIResponder doesNotRecognizeSelector:] + 232 4
CoreFoundation 0x0000000116f389f8 forwarding + 1280 5 CoreFoundation 0x0000000116f3ad1c _CF_forwarding_prep_0 + 92 6 Intercom
0x000000010bbb424c IntercomSDK_saveViewHierarchy + 474756 7
Intercom 0x000000010bbb41c8 IntercomSDK_saveViewHierarchy + 474624 8 Intercom
0x000000010bbb0fac IntercomSDK_saveViewHierarchy + 461796 9
Intercom 0x000000010bbb0f28 IntercomSDK_saveViewHierarchy + 461664 10 Intercom
0x000000010bb936dc IntercomSDK_saveViewHierarchy + 340756 11 Intercom 0x000000010bb93650 IntercomSDK_saveViewHierarchy + 340616 12 CoreFoundation
0x0000000116e6503c CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 140 13 CoreFoundation 0x0000000116e64f60 ___CFXRegistrationPost_block_invoke + 84 14 CoreFoundation 0x0000000116e64450 _CFXRegistrationPost + 404 15 CoreFoundation
0x0000000116e63e2c _CFXNotificationPost + 688 16 Foundation
0x00000001100fc0c0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 88 17 UIKitCore
0x000000012cf7a08c -[_UISceneLifecycleMonitor willEnterForeground] + 240 18 UIKitCore 0x000000012cf7ab0c __111-[_UIWindowSceneFBSSceneLifecycleMonitor transitionToTargetState:fromState:withTransitionContext:preparations:]_block_invoke_5

  • 120 19 UIKitCore 0x000000012d49279c _UIScenePerformActionsWithLifecycleActionMask + 96 20 UIKitCore 0x000000012cf7a9d0 __111-[_UIWindowSceneFBSSceneLifecycleMonitor transitionToTargetState:fromState:withTransitionContext:preparations:]_block_invoke_4
  • 128 21 UIKitCore 0x000000012cf8b1dc ___UISceneLifecycleSettingsUpdateBlockWithCanvasAndTransitionContext_block_invoke_2
  • 288 22 UIKitCore 0x000000012cf7a74c -[_UIWindowSceneFBSSceneLifecycleMonitor transitionToTargetState:fromState:withTransitionContext:preparations:]
  • 528 23 UIKitCore 0x000000012cf8af9c ___UISceneLifecycleSettingsUpdateBlockWithCanvasAndTransitionContext_block_invoke
  • 276 24 UIKitCore 0x000000012cf8c5d8 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_blo 25 UIKitCore 0x000000012d395170 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] + 656 26 UIKitCore 0x000000012d4a8950 _UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion
  • 196 27 UIKitCore 0x000000012cf8c304 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
  • 288 28 UIKitCore 0x000000012cdee1c4 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.198
  • 608 29 UIKitCore 0x000000012cdecf8c -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 232 30 UIKitCore 0x000000012cdede48 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220 31 UIKitCore 0x000000012d3bca3c -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 308 32 FrontBoardServices 0x000000011c7953b8 -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] + 560 33 FrontBoardServices 0x000000011c7be444 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2
  • 124 34 FrontBoardServices 0x000000011c7a0bb4 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 160 35 FrontBoardServices 0x000000011c7be390 __94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke
  • 312 36 libdispatch.dylib 0x000000011780d93c _dispatch_client_callout + 16 37 libdispatch.dylib 0x0000000117811534 _dispatch_block_invoke_direct + 392 38 FrontBoardServices 0x000000011c7dffa0 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 44 39 FrontBoardServices 0x000000011c7dfe7c -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible] + 196 40 FrontBoardServices 0x000000011c7dffd4 -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource] + 24 41 CoreFoundation 0x0000000116e9569c CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 24 42 CoreFoundation 0x0000000116e955e4 __CFRunLoopDoSource0 + 172 43 CoreFoundation 0x0000000116e94d54 __CFRunLoopDoSources0 + 232 44 CoreFoundation
    0x0000000116e8f43c __CFRunLoopRun + 768 45 CoreFoundation
    0x0000000116e8ed28 CFRunLoopRunSpecific + 572 46 GraphicsServices
    0x000000011c2d7bc0 GSEventRunModal + 160 47 UIKitCore
    0x000000012d8c3fdc -[UIApplication _run] + 868 48 UIKitCore
    0x000000012d8c7c54 UIApplicationMain + 124 49 NugttahDev
    0x000000010256f8d4 main + 64 50 dyld
    0x000000010500d558 start_sim + 20 51 ???
    0x00000001050ee0e0 0x0 + 4379828448 52 ???
    0x5a1d800000000000 0x0 + 6493486975226478592 ) libc++abi: terminating due to uncaught exception of type NSException

Solution

  • Adding this fixed the issue

    extension CPTemplateApplicationScene {
        @objc var windows: UIWindow? { nil }
    }