App is crashing when UINavigationController is initialised with root view controller

The method called from app delegate didfinishlaunching and at the line, initWithRootViewController app is crashing on iOS 13.4, iPad 5th Generation. This problem is not coming every time. I got this stack trace of exception from firebase crashlytics.


- (void)userLoginUsingNewData
{
LoginViewController *loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
self.mainNavigationController = [[UINavigationController alloc] initWithRootViewController:loginViewController];
[self.mainNavigationController setNavigationBarHidden:YES];
[self.window setRootViewController:_MAGICBOX.mainNavigationController];
[self.window makeKeyAndVisible];
}


Fatal Exception: NSInvalidArgumentException
-[__NSCFType fontDescriptorByAddingAttributes:]: unrecognized selector sent to instance 0x280183420


Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x197058a48 __exceptionPreprocess
1 libobjc.A.dylib 0x196d7ffa4 objc_exception_throw
2 CoreFoundation 0x196f5c5a8 -[NSOrderedSet initWithSet:copyItems:]
3 CoreFoundation 0x19705caf4 ___forwarding___
4 CoreFoundation 0x19705ea7c _CF_forwarding_prep_0
5 UIFoundation 0x19a67530c __UIFontDescriptorWithTextStyle
6 UIFoundation 0x19a62f6f0 +[UIFontDescriptor preferredFontDescriptorWithTextStyle:addingSymbolicTraits:options:]
7 UIKitCore 0x19b42fe40 _ensureLargeFontGlobals.llvm.1284539462740725553
8 UIKitCore 0x19b42f9ec __UIInnerNavTitleAppearanceAddDefaultLargeTitleAttributes
9 UIKitCore 0x19a8350f0 -[_UINavigationBarVisualProviderModernIOS prepare]
10 UIKitCore 0x19a7e5bac -[UINavigationBar _commonNavBarInit]
11 UIKitCore 0x19a7e5d04 -[UINavigationBar initWithFrame:]
12 UIKitCore 0x19aa24828 -[UINavigationController _navigationBarHiddenByDefault:]
13 UIKitCore 0x19aa2b8e4 -[UINavigationController loadView]
14 UIKitCore 0x19aac3c5c -[UIViewController loadViewIfRequired]
15 UIKitCore 0x19aac4360 -[UIViewController view]
16 UIKitCore 0x19aa39c54 -[UINavigationController pushViewController:transition:forceImmediate:]
17 UIKitCore 0x19aa398ac -[UINavigationController pushViewController:animated:]
18 UIKitCore 0x19aa1cdd8 -[UINavigationController initWithRootViewController:]
19 SMP eReader 0x100a4dff4 +[AppLaunch userLoginUsingNewData] + 160 (AppLaunch.m:160)
20 SMP eReader 0x100a4d894 +[AppLaunch setupAppRootViewWithAppUpgrade] + 108 (AppLaunch.m:108)
21 SMP eReader 0x100ae5140 -[AppDelegate application:didFinishLaunchingWithOptions:] + 42 (AppDelegate.m:42)
22 UIKitCore 0x19b0d4ee4 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
23 UIKitCore 0x19b0d6ca0 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:]
24 UIKitCore 0x19b0dc42c -[UIApplication _runWithMainScene:transitionContext:completion:]
25 UIKitCore 0x19a8a9208 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:]
26 UIKitCore 0x19ad3f698 _UIScenePerformActionsWithLifecycleActionMask
27 UIKitCore 0x19a8a9cf0 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke
28 UIKitCore 0x19a8a9748 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
29 UIKitCore 0x19a8a9b1c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
30 UIKitCore 0x19a8a93d8 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
31 UIKitCore 0x19a8ad8c4 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2
32 UIKitCore 0x19ac70f08 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:]
33 UIKitCore 0x19ad58c84 _UISceneSettingsDiffActionPerformChangesWithTransitionContext
34 UIKitCore 0x19a8ad5fc __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
35 UIKitCore 0x19ad58b80 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext
36 UIKitCore 0x19a8ad468 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
37 UIKitCore 0x19a71f2c0 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke
38 UIKitCore 0x19a71de28 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
39 UIKitCore 0x19a71eff8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
40 UIKitCore 0x19b0da7e4 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:]
41 UIKitCore 0x19ac91900 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:]
42 FrontBoardServices 0x19c18b7a0 -[FBSSceneImpl _callOutQueue_agent_didCreateWithTransitionContext:completion:]
43 FrontBoardServices 0x19c1b0838 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke.154
44 FrontBoardServices 0x19c195f04 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
45 FrontBoardServices 0x19c1b04f4 __86-[FBSWorkspaceScenesClient sceneID:createWithParameters:transitionContext:completion:]_block_invoke
46 libdispatch.dylib 0x196d25184 _dispatch_client_callout
47 libdispatch.dylib 0x196ccdfd8 _dispatch_block_invoke_direct$VARIANT$mp
48 FrontBoardServices 0x19c1d5418 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
49 FrontBoardServices 0x19c1d50e4 -[FBSSerialQueue _queue_performNextIfPossible]
50 FrontBoardServices 0x19c1d560c -[FBSSerialQueue _performNextFromRunLoopSource]
51 CoreFoundation 0x196fd6a00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
52 CoreFoundation 0x196fd6958 __CFRunLoopDoSource0
53 CoreFoundation 0x196fd60f0 __CFRunLoopDoSources0
54 CoreFoundation 0x196fd123c __CFRunLoopRun
55 CoreFoundation 0x196fd0adc CFRunLoopRunSpecific
56 GraphicsServices 0x1a0f71328 GSEventRunModal
57 UIKitCore 0x19b0de63c UIApplicationMain
58 SMP eReader 0x100b5f82c main + 14 (main.m:14)
59 libdyld.dylib 0x196e5a360 start

Replies

1) please insert code in one of those boxes that you get by using the "<>" key above this edit window.

2) from the crash log, your app is never calling your method "userLoginUsingNewData"

3) there is a typo in the line that you attribute to teh crash "UINavigationContrller"

4) it appears that the crash is in the init routine in the instatiated LoginViewController

5) it appears the crash has something to do with UINavigationBar in LoginViewController - are you asking the system to place multiple elements in that Nav Bar that might require the system placing them in an NSSet and something is preventing the system from copying those elements perhaps because of a font?

I see that you edited your initial post to address issue #3. Nicely done. Do you understand the other issues? have you explored the questions mentioned in number 5:


5) it appears the crash has something to do with UINavigationBar in LoginViewController - are you asking the system to place multiple elements in that Nav Bar that might require the system placing them in an NSSet and something is preventing the system from copying those elements perhaps because of a font?