Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App crashes with "Could not instantiate class named _UIScrollViewLayoutGuide" on iOS 10 and older

I have been getting the below error and none of the existing Stack Overflow answers helped. I am poor at finding the exact location where error is formed by looking console results.

This is the error I get when I run in older devices (works fine in newer devices). What things can I try to determine the problem?

2019-12-30 16:52:04.784 Hospital[7075:164758] *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named _UIScrollViewLayoutGuide'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010ad9fb0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010a804141 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010ae08625 +[NSException raise:format:] + 197

    3   UIKit                               0x000000010c15368d UINibDecoderDecodeObjectForValue + 323

    4   UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    5   Foundation                          0x0000000109b0e417 -[NSLayoutConstraint initWithCoder:] + 757
    6   UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693

    7   UIKit                               0x000000010c15399d UINibDecoderDecodeObjectForValue + 1107

    8   UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    9   UIKit                               0x000000010bbee9de -[UIView initWithCoder:] + 2209
    10  UIKit                               0x000000010bc29687 -[UIScrollView initWithCoder:] + 71
    11  UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693
    12  UIKit                               0x000000010c15399d UINibDecoderDecodeObjectForValue + 1107
    13  UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    14  UIKit                               0x000000010bbee4ed -[UIView initWithCoder:] + 944
    15  UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693

    16  UIKit                               0x000000010c15353f -[UINibDecoder decodeObjectForKey:] + 89
    17  UIKit                               0x000000010bf62f70 -[UIRuntimeConnection initWithCoder:] + 178
    18  UIKit                               0x000000010c1537ff UINibDecoderDecodeObjectForValue + 693
    19  UIKit                               0x000000010c15399d UINibDecoderDecodeObjectForValue + 1107
    20  UIKit                               0x000000010c15353f -[UINibDecoder a:] + 89
    21  UIKit                               0x000000010bf6216d -[UINib instantiateWithOwner:options:] + 1262
    22  UIKit                               0x000000010bcfcfc3 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
    23  UIKit                               0x000000010bcfd8d9 -[UIViewController loadView] + 177
    24  UIKit                               0x000000010bcfdc0a -[UIViewController loadViewIfRequired] + 195
    25  UIKit                               0x000000010bcfe45a -[UIViewController view] + 27
    26  Hospital                     0x00000001086ecb00 $s15_Hospital15PagerScrollViewC03setcdE010toParentVC05pagesI0ySo16UIViewControllerC_SayAHGSgtF + 1152
    27  Hospital                     0x00000001086f6b85 $s15_Hospital22HomeMainViewControllerC11viewDidLoadyyF + 3861
    28   Hospital                     0x00000001086f6e9b $s15_Hospital22HomeMainViewControllerC11viewDidLoadyyFTo + 43
    29  UIKit                               0x000000010bcfe01a -[UIViewController loadViewIfRequired] + 1235
    30  UIKit                               0x000000010bd3ce6c -[UINavigationController _layoutViewController:] + 56
    31  UIKit                               0x000000010bd3d74a -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 466
    32  UIKit                               0x000000010bd3d8bb -[UINavigationController _startTransition:fromViewController:toViewController:] + 127
    33  UIKit                               0x000000010bd3ea03 -[UINavigationController _startDeferredTransitionIfNeeded:] + 843
    34  UIKit                               0x000000010bd3fb41 -[UINavigationController __viewWillLayoutSubviews] + 58
    35  UIKit                               0x000000010bf3160c -[UILayoutContainerView layoutSubviews] + 231
    36  UIKit                               0x000000010bc1e55b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
    37  QuartzCore                          0x000000010a572904 -[CALayer layoutSublayers] + 146
    38  QuartzCore                          0x000000010a566526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
    39  QuartzCore                          0x000000010a5663a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    40  QuartzCore                          0x000000010a4f5e92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    41  QuartzCore                          0x000000010a522130 _ZN2CA11Transaction6commitEv + 468
    42  QuartzCore                          0x000000010a522b37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
    43  CoreFoundation                      0x000000010ad45717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23

    44  CoreFoundation                      0x000000010ad45687 __CFRunLoopDoObservers + 391
    45  CoreFoundation                      0x000000010ad2a038 CFRunLoopRunSpecific + 440
    46  UIKit                               0x000000010bb5508f -[UIApplication _run] + 468
    47  UIKit                               0x000000010bb5b134 UIApplicationMain + 159
    48   Hospital                     0x000000010872773b main + 75
    49  libdyld.dylib                       0x000000010e5d965d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
like image 928
Jaseel.Dev Avatar asked Dec 30 '19 11:12

Jaseel.Dev


2 Answers

I had the same issue (using Xcode11 and running iOS 10.3.1). Unchecking Content Layout Guides from the Scroll View worked for me.

image

like image 142
Luke Avatar answered Nov 14 '22 22:11

Luke


Thanks to @Luke's answer I've found the exact reason of the problem: it is caused by constraints between any item and scroll view's Content Layout Guide.

So to find where the problem one needs to:

  1. check the log to find out which view controller participates in the problem. According to the log shown by @Jaseel.Dev it is "Alexis_Hospital"
  2. In that view controller in Interface Builder check all scroll views and their Content Layout Guides or Frame Layout Guides
  3. There 2 ways to fix:

a) click on the scroll view, there Uncheck [ ] Content Layout Guides and check them again (Interface Builder will reassign the "layout guide" edges to "superview")

enter image description here

b) click on the Content Autolayout Guide and check if there any constraints pointing to them. Get rid of those constraints.

enter image description here

The main idea is to remove these constrains, which would crash on iOS 10 and earlier.

like image 32
Vitalii Avatar answered Nov 14 '22 22:11

Vitalii