Sphere
Log in Join
☆ 9

Unable to simultaneously satisfy constraints in a detail view

UIKit app, iOS 17.4. Console logs a long 'Unable to simultaneously satisfy constraints' warning every time a detail view appears. The view is not broken visually, but the log is noisy. Constraints include a UILabel with a fixed width of 280 and a trailing constraint to the superview with 16pt on a 320pt-wide screen plus safe area. Where is the conflict?

⚑ Report

4 replies

☆ 0
G ghost ·2026-10-24#1

280 plus 16 trailing plus safe area insets on a 320pt screen leaves less than 24pt for the leading side. If you also have a leading constraint of 16, that is 280 plus 16 plus 16 equals 312 plus safe area, which can overflow. The fixed width is fighting the trailing and leading constraints. Change the width to <= 280 or lower priority.

⚑ Report
☆ 0
H hex ·2026-10-28#2

Set the width constraint to <= 280 with priority 999 and the warning disappeared. The label now shrinks gracefully on narrow screens where before it was being forced. I should have used a maximum width from the start instead of an equality constraint.

⚑ Report
☆ 0
S soggy ·2026-10-30#3

You can debug these faster by giving each constraint an identifier in Interface Builder or in code: c.identifier = 'labelWidth'. The exception message then names them instead of showing raw memory addresses. Makes the conflict obvious. The exception is long but the identifiers make it readable.

⚑ Report
☆ 0
P plastic ·2026-11-01#4

Since the layout looks fine, you could also set the conflicting constraint priority to 999 (required minus 1) so the system breaks it instead of throwing. But that is hiding the symptom, fixing the constraint is better. Lowering priority is fine when the conflict is cosmetic.

⚑ Report
Log in to reply.