iOS 26 Degenerate Layout Crash caused by UIStackView
If you have a complex Auto Layout setup like I do, you may encounter a ‘Degenerate Layout’ crash when you upgrade your app to the iOS 26 SDK. The error will look like this:
Thread 1: "Degenerate layout! Layout feedback loop detected in subtree of <UIStackView: 0x103a7c430; frame = (0 0; 402 874); wants auto layout; tAMIC = NO; >. More info may be available in the log for com.apple.UIKit.LayoutLoop"
The root cause was that I set isLayoutMarginsRelativeArrangement to true on one of my UIStackViews. A change in UIKit’s layout system caused it to enter an infinite loop when there was an ambiguous layout.
buttonStackView.layoutMargins = UIEdgeInsets(top: 30.0,
left: EntryCell.layoutMargins.left,
bottom: 10.0,
right: EntryCell.layoutMargins.right)
buttonStackView.isLayoutMarginsRelativeArrangement = true
The fix is simple: avoid using UIStackView.isLayoutMarginsRelativeArrangement and replace it with a container view, with a little help from this layout gist: (UIView+Pin.swift).
let buttonContainer = UIView()
buttonContainer.addSubview(buttonStackView)
let insets = UIEdgeInsets(top: 30.0, left: EntryCell.layoutMargins.left, bottom: 10.0, right: EntryCell.layoutMargins.right)
buttonStackView.pinToEdges(of: buttonContainer, insets: insets)
Posted 2025-06-28