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.

  1. What is a UIIBSystemGenerated constraint?
  2. When is a UIIBSystemGenerated constraint created?
  3. Solution

What is a UIIBSystemGenerated constraint?

A 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 UICollectionViewCell class.

Solution

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.

UICollectionView Cell In Storyboard
UICollectionView Cell In Storyboard

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 customClass, customModule, and 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">

Deleting the customClass, customModule, and customModuleProvider keys from the xml file will resolve the issue.