Home > Net >  Finding Missing Constraint
Finding Missing Constraint

Time:02-01

When I build my app Xcode gives me five warnings relating to missing constraints. But clicking on them in the Navigation Panel only takes me to a ViewController in the Storyboard and doesn't highlight which view has the problem.

enter image description here

In addition, as shown above, the Storyboard doesn't contain any yellow triangles at all, so I'm at a loss as to how to find which view is missing the constraints.

The errors don't appear when I run the app, so how to I try to trap these errors in the build?

(Xcode 14.2)

CodePudding user response:

Xcode and Storyboards have lots of bugs...

One that you're encountering is the failure to show error/warning indicators.

This is how it should look:

enter image description here

Clicking that indicator will show you the specific warnings - and hovering over one shows you the view in question:

enter image description here

However, those indictors and descriptions are sometimes missing. Seems to happen most often when you have multiple view controllers in a single Storyboard.

You could copy each controller to a new Storyboard to see if the information shows up - but, based on my experience, it's hit-or-miss.

In your specific case, warnings such as:

Leading constraint is missing, which may cause overlapping with other views.

can be safely ignored... provided you know and understand the layout you've designed.

  • Related