I just updated to Xcode 11.5 and suddenly my application is throwing up this error (listed below).
My application has a TabBar as a foundation and houses different views for each of the five TabBar Items. All views work fine, except for the 3rd one, where on clicking the icon, I get the below error message.
This view has a segControl that changes data in a tableView. I've added pull to refresh and a search functionality. There's also a UILabel that appears when data can't be pulled / no internet scenario and is otherwise hidden.
Error
Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutYAxisAnchor:0x60000064b4c0 "UILabel:0x7fb6dd8b8b80'Day 1'.centerY"> and <NSLayoutYAxisAnchor:0x600000649780 "UIView:0x7fb6dd4b89d0.centerY"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'
Now, I haven't changed this piece of code at all and it was working perfectly fine till the update happened. So I'm confused how to fix it.
I see that there might be some label and view conflicting their constraint hierarchies but I can't seem to figure out which ones and how to fix them.
Also there is nothing in my code that refers to 'Day 1' and I'm not adding any subViews programmatically.
Troubleshooting done so far
Current Constraints [after discarding all code, working earlier]
label.top = top - 9
bottom = label.bottom + 1
label.leading = leading + 8
label.centerX = centerX
These are the only constrains, as I added a view below the tableView and that view contains the label.
[These are auto-constraints]
Appreciate any help. Thanks in advance.
Managed to figure out the bug - it seems the update flipped over a custom class I was using, which in turn missed the reference to a dependency.
After reverting the custom class (in the storyboard - tableViewCell) correctly, it worked.
The answer here was the inspiration to try out this solution.