Xcode 8 DETECTED_MISSING_CONSTRAINTS

Dear All,

After upgrading to Xcode 8 I had a lot of issues, mainly because of the SourceKit. But I believe that Apple team will fix all of those. Today I've upgraded to macOS Sierra and now when I run my project a strange warning (or maybe error) appears:


2016-09-22 09:13:08.908603 ********************* [1469:92122] [Layout] Detected missing constraints for <private>. It cannot be placed because there are not enough constraints to fully define the size and origin. Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once.


Any help on how to detect the object with the missing constraint or how to setup such breakpoint is much appreciated.


UPDATE:

It appear that the problem is related somehow to ... well ... bugs in autolayout implementation in 10.12. For example:


2016-10-04 13:20:16.182220 ************[64022:7194826]
[Layout] Detected missing constraints for <private>.
It cannot be placed because there are not enough constraints to fully define the size and origin.
Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once.
(lldb) po $arg1
<NSSplitDividerView: 0x610000162e80>


The above is happening when collapsing a slit view item via a button.


UPDATE: 10.10.2016 An example can be downloaded from https://github.com/ivailon/test-12

It will be nice if someone can confirm it. It will save a lot of tension to all developers ;-)


I.

Replies

Same situation here this morning. We are getting this error message in places where we call layoutSubtreeIfNeeded on NSView. Set a symbolic breakpoint with "DETECTED_MISSING_CONSTRAINTS" as the symbol to debug.


Any help with the cause and/or a solution is much appreciated!

The same problem with my NSTableView. But i can't reappear it in a new project.

>Any help on how to detect the object with the missing constraint or how to setup such breakpoint is much appreciated.


See: TN2239: Technical Note TN2239: iOS Debugging Magic/ Some Assembly Required


Setting breakpoint basics see:
Managing Breakpoints

OK - a little bit of lightning. Obviously Apple did many changes in the auto-layout system. There is new "Autoresizing" submenu in the "Size inspector" for the views. Setting the parameters of this (familiar from the past) menu is making a difference. More investigation needed ;-)


I.

There seems to be a discssion of the changes in the 10.12 realease notes. I get the gist of it, but not sure how to remedy.


https://developer.apple.com/library/content////releasenotes/AppKit/RN-AppKit/index.html#10_12Layout

I will add that the error occurs for me when opening a file open dialog box from a view controller containing multiple scrollview tables. However, using breakpoints, the error is found to occur exactly when the open file dialog appears and not when updating (knowingly, anyway) anything in the view window. Or if the dialog itself isn't the problem, perhaps overlaying it over my view causes the view to be declared as dirty thereby triggering the warning.


gw

OK - things will get clear at some point. Thank you for the link - it's very useful in my case.


I.

I can trigger this message simply by calling NSAlert.layout() to force the alert to lay itself out immediately. (You might do this when adding accessory views or to get the resized window frame when using a long message text.) Since none of the suggestions work in this case and there is no obvious way to avoid the error, I filed a radar (rdar://problem/28700495); feel free to dupe this.

I am having a very similar issue: http://stackoverflow.com/questions/40404846/new-auto-layout-errors-with-xcode-8-1

Hi,

I'm getting the same warning. In my case it's a NSSplitViewController with a nested NSTabViewController into one of the splitview items.

I cannot get it fixed because it's a private subclass of NSView triggering the problem: _NSSplitViewItemViewWrapper.

The warning gets triggered either if I use storyboard ot I use nib files and add the splitview items programmatically.