iOS: Layout Constraint errors when typing or searching for emojis in keyboard (The behavior of the UICollectionViewFlowLayout is not defined)

Viewed 218

I am new to iOS development so bear with me.

Xcode Version: 12.5.1 Testing device version: iOS 14.7.1

Note: I do not have a UICollectionView.

As part of a larger app, I have a view controller in the storyboard. This view controller is not linked to a custom class or anything. In it I have a UITextField horizontally and vertically centered in a UIView. The UIView has top left right and bottom constraints to super view with constant 0 for each. When I run this on a real device and type letters in the text field, everything is fine but if I try to add an emoji I get constraint errors. Also if I try to search for an emoji in the emoji search bar on the keyboard I get a constraint error log with every letter I type.

What could be the problem?

Edit: (After posting this, I tried this in a new Xcode Project, I added a UITextField, centered it in container, and ran on a device. When I tried to type emojis I got the same errors linked here! )

Here is what my view controller looks like in the storyboard and what my UITextField Attributes look like:

Image showing view controller in story board.

Here is a dump of the layout constraint errors I get.

2021-09-17 09:04:01.515699+0200 Safespace[6815:1866398] The behavior of the UICollectionViewFlowLayout is not defined because:
2021-09-17 09:04:01.515833+0200 Safespace[6815:1866398] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2021-09-17 09:04:01.516295+0200 Safespace[6815:1866398] The relevant UICollectionViewFlowLayout instance is <_InvertibleFlowLayout: 0x14d61b8a0>, and it is attached to <UICollectionView: 0x14e80c800; frame = (0 0; 154 2); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x2828c76c0>; layer = <CALayer: 0x2826213e0>; contentOffset: {0, 0}; contentSize: {16, 2}; adjustedContentInset: {0, 0, 0, 0}; layout: <_InvertibleFlowLayout: 0x14d61b8a0>; dataSource: <__UIDiffableDataSource 0x281954c30: sectionCounts=[_UIDataSourceSnapshotter - 0x2826c3500:(0:36)]; sections=[0x2826c34c0]; identifiers=[0x2826c33e0]>>.
2021-09-17 09:04:01.516367+0200 Safespace[6815:1866398] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2021-09-17 09:04:01.519841+0200 Safespace[6815:1866398] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x28050dc20 H:|-(0)-[TUIEmojiSearchView:0x14d404480]   (active, names: '|':TUIEmojiSearchInputView:0x14bd385c0 )>",
    "<NSLayoutConstraint:0x28050dd10 TUIEmojiSearchView:0x14d404480.trailing == TUIEmojiSearchInputView:0x14bd385c0.trailing   (active)>",
    "<NSLayoutConstraint:0x280572940 'searchField.leading' H:|-(8)-[TUIEmojiSearchTextField:0x14f021e00]   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x280572990 'searchField.trailing' H:[TUIEmojiSearchTextField:0x14f021e00]-(8)-|   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x2805330c0 'UIView-Encapsulated-Layout-Width' TUIEmojiSearchInputView:0x14bd385c0.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x280572990 'searchField.trailing' H:[TUIEmojiSearchTextField:0x14f021e00]-(8)-|   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-09-17 09:04:01.521558+0200 Safespace[6815:1866398] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x28050d900 H:|-(0)-[UILayoutGuide:0x281f55b20'predictionViewGuide']   (active, names: '|':UIView:0x14d61b360 )>",
    "<NSLayoutConstraint:0x28050e260 H:[UILayoutGuide:0x281f55b20'predictionViewGuide']-(6)-|   (active, names: '|':UIView:0x14d61b360 )>",
    "<NSLayoutConstraint:0x28050dc20 H:|-(0)-[TUIEmojiSearchView:0x14d404480]   (active, names: '|':TUIEmojiSearchInputView:0x14bd385c0 )>",
    "<NSLayoutConstraint:0x28050dd10 TUIEmojiSearchView:0x14d404480.trailing == TUIEmojiSearchInputView:0x14bd385c0.trailing   (active)>",
    "<NSLayoutConstraint:0x280572a30 'bottomContainer.leading' H:|-(0)-[UIView:0x14d412cc0]   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x280572ad0 'bottomContainer.trailing' H:[UIView:0x14d412cc0]-(0)-|   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x28050d860 'predictionViewWrapper.leading' H:|-(0)-[UIView:0x14d61b360]   (active, names: '|':UIView:0x14d412cc0 )>",
    "<NSLayoutConstraint:0x28050dcc0 'predictionViewWrapper.trailing' H:[UIView:0x14d61b360]-(0)-|   (active, names: '|':UIView:0x14d412cc0 )>",
    "<NSLayoutConstraint:0x2805330c0 'UIView-Encapsulated-Layout-Width' TUIEmojiSearchInputView:0x14bd385c0.width == 0   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x28050e260 H:[UILayoutGuide:0x281f55b20'predictionViewGuide']-(6)-|   (active, names: '|':UIView:0x14d61b360 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-09-17 09:04:01.522221+0200 Safespace[6815:1866398] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x28050da40 V:|-(0)-[TUIEmojiSearchView:0x14d404480]   (active, names: '|':TUIEmojiSearchInputView:0x14bd385c0 )>",
    "<NSLayoutConstraint:0x28050d9f0 TUIEmojiSearchView:0x14d404480.bottom == TUIEmojiSearchInputView:0x14bd385c0.bottom   (active)>",
    "<NSLayoutConstraint:0x280572a80 'bottomContainer.bottom' V:[UIView:0x14d412cc0]-(0)-|   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x2805728f0 'searchField.height' TUIEmojiSearchTextField:0x14f021e00.height == 37   (active)>",
    "<NSLayoutConstraint:0x2805727b0 'searchField.top' V:|-(10)-[TUIEmojiSearchTextField:0x14f021e00]   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x280533110 'UIView-Encapsulated-Layout-Height' TUIEmojiSearchInputView:0x14bd385c0.height == 0   (active)>",
    "<NSLayoutConstraint:0x2805729e0 'verticalSearchSpacing' V:[TUIEmojiSearchTextField:0x14f021e00]-(0)-[UIView:0x14d412cc0]   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x2805728f0 'searchField.height' TUIEmojiSearchTextField:0x14f021e00.height == 37   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-09-17 09:04:01.522824+0200 Safespace[6815:1866398] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x28050da40 V:|-(0)-[TUIEmojiSearchView:0x14d404480]   (active, names: '|':TUIEmojiSearchInputView:0x14bd385c0 )>",
    "<NSLayoutConstraint:0x28050d9f0 TUIEmojiSearchView:0x14d404480.bottom == TUIEmojiSearchInputView:0x14bd385c0.bottom   (active)>",
    "<NSLayoutConstraint:0x280572a80 'bottomContainer.bottom' V:[UIView:0x14d412cc0]-(0)-|   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x2805727b0 'searchField.top' V:|-(10)-[TUIEmojiSearchTextField:0x14f021e00]   (active, names: '|':TUIEmojiSearchView:0x14d404480 )>",
    "<NSLayoutConstraint:0x280533110 'UIView-Encapsulated-Layout-Height' TUIEmojiSearchInputView:0x14bd385c0.height == 0   (active)>",
    "<NSLayoutConstraint:0x2805729e0 'verticalSearchSpacing' V:[TUIEmojiSearchTextField:0x14f021e00]-(0)-[UIView:0x14d412cc0]   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x2805729e0 'verticalSearchSpacing' V:[TUIEmojiSearchTextField:0x14f021e00]-(0)-[UIView:0x14d412cc0]   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-09-17 09:04:01.525469+0200 Safespace[6815:1866398] The behavior of the UICollectionViewFlowLayout is not defined because:
2021-09-17 09:04:01.525544+0200 Safespace[6815:1866398] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2021-09-17 09:04:01.525691+0200 Safespace[6815:1866398] The relevant UICollectionViewFlowLayout instance is <_InvertibleFlowLayout: 0x14d61b8a0>, and it is attached to <UICollectionView: 0x14e80c800; frame = (0 0; 414 2); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x2828c76c0>; layer = <CALayer: 0x2826213e0>; contentOffset: {0, 0}; contentSize: {-206, 2}; adjustedContentInset: {0, 0, 0, 0}; layout: <_InvertibleFlowLayout: 0x14d61b8a0>; dataSource: <__UIDiffableDataSource 0x281954c30: sectionCounts=[_UIDataSourceSnapshotter - 0x2826c3500:(0:36)]; sections=[0x2826c34c0]; identifiers=[0x2826c33e0]>>.
2021-09-17 09:04:01.525740+0200 Safespace[6815:1866398] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2021-09-17 09:04:01.526188+0200 Safespace[6815:1866398] The behavior of the UICollectionViewFlowLayout is not defined because:
2021-09-17 09:04:01.526230+0200 Safespace[6815:1866398] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2021-09-17 09:04:01.526344+0200 Safespace[6815:1866398] The relevant UICollectionViewFlowLayout instance is <_InvertibleFlowLayout: 0x14d61b8a0>, and it is attached to <UICollectionView: 0x14e80c800; frame = (0 0; 414 2); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x2828c76c0>; layer = <CALayer: 0x2826213e0>; contentOffset: {0, 0}; contentSize: {-206, 2}; adjustedContentInset: {0, 0, 0, 0}; layout: <_InvertibleFlowLayout: 0x14d61b8a0>; dataSource: <__UIDiffableDataSource 0x281954c30: sectionCounts=[_UIDataSourceSnapshotter - 0x2826c3500:(0:36)]; sections=[0x2826c34c0]; identifiers=[0x2826c33e0]>>.
2021-09-17 09:04:01.526386+0200 Safespace[6815:1866398] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2021-09-17 09:04:01.527890+0200 Safespace[6815:1866398] The behavior of the UICollectionViewFlowLayout is not defined because:
2021-09-17 09:04:01.527951+0200 Safespace[6815:1866398] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2021-09-17 09:04:01.528090+0200 Safespace[6815:1866398] The relevant UICollectionViewFlowLayout instance is <_InvertibleFlowLayout: 0x14d61b8a0>, and it is attached to <UICollectionView: 0x14e80c800; frame = (0 0; 414 4); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x2828c76c0>; layer = <CALayer: 0x2826213e0>; contentOffset: {0, 0}; contentSize: {-206, 2}; adjustedContentInset: {0, 0, 0, 0}; layout: <_InvertibleFlowLayout: 0x14d61b8a0>; dataSource: <__UIDiffableDataSource 0x281954c30: sectionCounts=[_UIDataSourceSnapshotter - 0x2826c3500:(0:36)]; sections=[0x2826c34c0]; identifiers=[0x2826c33e0]>>.
2021-09-17 09:04:01.528137+0200 Safespace[6815:1866398] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2021-09-17 09:04:01.528285+0200 Safespace[6815:1866398] The behavior of the UICollectionViewFlowLayout is not defined because:
2021-09-17 09:04:01.528326+0200 Safespace[6815:1866398] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2021-09-17 09:04:01.528435+0200 Safespace[6815:1866398] The relevant UICollectionViewFlowLayout instance is <_InvertibleFlowLayout: 0x14d61b8a0>, and it is attached to <UICollectionView: 0x14e80c800; frame = (0 0; 414 4); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x2828c76c0>; layer = <CALayer: 0x2826213e0>; contentOffset: {0, 0}; contentSize: {-312, 4}; adjustedContentInset: {0, 0, 0, 0}; layout: <_InvertibleFlowLayout: 0x14d61b8a0>; dataSource: <__UIDiffableDataSource 0x281954c30: sectionCounts=[_UIDataSourceSnapshotter - 0x2826c3500:(0:36)]; sections=[0x2826c34c0]; identifiers=[0x2826c33e0]>>.
2021-09-17 09:04:01.528477+0200 Safespace[6815:1866398] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
2021-09-17 09:04:01.586090+0200 Safespace[6815:1866398] The behavior of the UICollectionViewFlowLayout is not defined because:
2021-09-17 09:04:01.586138+0200 Safespace[6815:1866398] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2021-09-17 09:04:01.586216+0200 Safespace[6815:1866398] The relevant UICollectionViewFlowLayout instance is <_InvertibleFlowLayout: 0x14d61b8a0>, and it is attached to <UICollectionView: 0x14e80c800; frame = (0 0; 414 4); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x2828c76c0>; layer = <CALayer: 0x2826213e0>; contentOffset: {0, 0}; contentSize: {-630, 4}; adjustedContentInset: {0, 0, 0, 0}; layout: <_InvertibleFlowLayout: 0x14d61b8a0>; dataSource: <__UIDiffableDataSource 0x281954c30: sectionCounts=[_UIDataSourceSnapshotter - 0x2826c3500:(0:36)]; sections=[0x2826c34c0]; identifiers=[0x2826c33e0]>>.
2021-09-17 09:04:01.586246+0200 Safespace[6815:1866398] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

1 Answers

I tested this and apparently, this only happens on iOS 14.x (Specifically was happening on 14.5 - 14.7 devices and simulators). Testing on a simulator with iOS 13.0 doesn't produce these errors which makes sense since the emoji search view is absent from iOS 13 and earlier. Still not sure what the actual error reason is - especially because I have tried it separate fresh projects with single view controllers and basic constraints with the same result. Could be an Apple bug, but I have no idea.

Related