'Constraints run successfully in simulator but get errors on device
I have an app that runs without any build error or warnings. The app runs successfully on simulator (no console error) but when I run on my real device I get the following console error:
2022-02-07 15:40:30.507950-0400 SalesTax[11923:142076] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x6000037618b0 UITableView:0x15c871c00.width == 186 (active)>",
"<NSLayoutConstraint:0x600003762850 H:|-(0)-[UITableView:0x15c871c00] (active, names: '|':UIStackView:0x15b62cc90 )>",
"<NSLayoutConstraint:0x6000037637a0 H:|-(20)-[UITextField:0x15c839600] (active, names: '|':UIView:0x15b6138a0 )>",
"<NSLayoutConstraint:0x6000037637f0 UITextField:0x15c839600.leading == UIButton:0x15b6245f0'Country California'.leading (active)>",
"<NSLayoutConstraint:0x600003763ac0 UIStackView:0x15b62cc90.leading == UIButton:0x15b6245f0'Country California'.leading (active)>",
"<NSLayoutConstraint:0x600003763b10 H:[UIStackView:0x15b62cc90]-(18)-| (active, names: '|':UIView:0x15b6138a0 )>",
"<NSLayoutConstraint:0x60000376c0a0 UIView:0x15b6138a0.width == UIScrollView:0x15c85d200.width (active)>",
"<NSLayoutConstraint:0x60000376c410 UILayoutGuide:0x600002d13b80'UIViewSafeAreaLayoutGuide'.trailing == UIScrollView:0x15c85d200.trailing (active)>",
"<NSLayoutConstraint:0x60000376c460 UIScrollView:0x15c85d200.leading == UILayoutGuide:0x600002d13b80'UIViewSafeAreaLayoutGuide'.leading (active)>",
"<NSLayoutConstraint:0x600003715680 'UISV-canvas-connection' H:[UITableView:0x15c871c00]-(0)-| (active, names: '|':UIStackView:0x15b62cc90 )>",
"<NSLayoutConstraint:0x600003768c30 'UIView-Encapsulated-Layout-Width' UIView:0x15b613dd0.width == 428 (active)>",
"<NSLayoutConstraint:0x60000376c320 'UIViewSafeAreaLayoutGuide-left' H:|-(0)-[UILayoutGuide:0x600002d13b80'UIViewSafeAreaLayoutGuide'](LTR) (active, names: '|':UIView:0x15b613dd0 )>",
"<NSLayoutConstraint:0x60000376c3c0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide:0x600002d13b80'UIViewSafeAreaLayoutGuide']-(0)-|(LTR) (active, names: '|':UIView:0x15b613dd0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000037618b0 UITableView:0x15c871c00.width == 186 (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Optional(18.0)
Message from debugger: Terminated due to signal 9
Layout is the same on simulator and device, but a dropdown menu title doesn't show its title on my iPhone device. I know that is a constraint problem, but I can't identify the view object constraints that cause the problem. Please consider that it's my first time using Xcode and Swift.
Solution 1:[1]
Solution:
On size inspector, horizontal width of some of my labels constraints, I changed the priority from 1000 to 750. That removed the error messages.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Richard |




