How do I find out who adds a specific auto layout constraint?
Because I'm seeing some constraints which I'm certain I did not add.
How do I find out who adds a specific auto layout constraint?
Because I'm seeing some constraints which I'm certain I did not add.
In Swift you could look at var identifier: String?
. If it starts with NS
then it was added by iOS.
A constraint’s identifier is available in its description. Identifiers that start with NS are reserved by the system.
If the layout is ambiguous or unsatisfiable, you can put a symbolic breakpoint on UIViewAlertForUnsatisfiableConstraints
.
You can add a Debugger Command
containing po [[UIWindow keyWindow] _autolayoutTrace]
for Objective-C or expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]
for Swift which automatically prints the UIView
hierarchy, as desribed in this article.
You can also use po $r15
in the debugger to print the "details description of constraint that is broken" or po $r14
for "more detailed description of all constraints added in addition to breaking constraint", as described in this article.
If not, you can set the accessibilityIdentifier
for your UIView
(or directly in the IB) which will show up in the previous expressions' results (and other places too) instead of the string UIView
.