Is Xcode AutoLayout breaking on a constraint that looks like this?
Will attempt to recover by breaking constraint <NSLayoutConstraint:0x600003aa2620 'UIIBSystemGenerated'
Autolayout may break and fail to render your views correctly in the case of conflicting constraints. In many cases, you can identify and fix incorrect or incomplete constraints using the logs generated and tools like wtfautolayout.com.
In the case of a
UIIBSystemGenerated constraint, these tools are unlikely to help as the root cause is likely not an incorrect or incomplete constraint.
What is a UIIBSystemGenerated constraint?
UIIBSystemGenerated is a constraint generated by Interface Builder automatically and applied to your view. Another example of an automatically generated constraint is a
NSAutoresizingMaskLayoutConstraint derived from the autoresizing masks applied to your view.
When is a UIIBSystemGenerated constraint created?
There may be multiple scenarios where a
UIIBSystemGenerated constraint is created. One potential root cause may be missetting the Content View on a
UICollectionViewCell in Interface Builder with a custom
Removing the incorrect class assignment on the Content View fixes the
UIIBSystemGenerated breaking constraint.
For illustration purposes, if you click on the white part of the cell in the image you will select the Content View. If you click on the handles around the white part, you will select the Collection View Cell. It’s easy to misclick and select the wrong one, leading to the incorrectly set Content View class.
Another way to verify this may be happening is to right-click on your .xib file and select “Open As -> Source Code”. This will show the xml representation of the interface. Look for the
collectionViewCellContentView xml node and then for the
customModuleProvider keys. An example:
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="csD-91-oPm" customClass="CustomCollectionViewCell" customModule="my_app" customModuleProvider="target">
customModuleProvider keys from the xml file will resolve the issue.
FREE all Swift Loading Animations
Immediately get access to commented code for these animations when you follow Advanced Swift.