Home » Swift » New auto layout errors with Xcode 8.1

New auto layout errors with Xcode 8.1

Posted by: admin November 30, 2017 Leave a comment


Heading ##I have a macOS app that was running just fine until I upgraded to Xcode 8.1.

The app opens a dialogue with NSOpenPanel to allow the user to choose an image. When I select an image and choose “Open” I get the following error:

2016-11-03 10:23:25.589283 PA Places Data[9008:265214] [Layout] Detected missing constraints for NSTextField: 0x6000001e3a00. 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.

The open dialogue then freezes and cannot be dismissed.

As suggested, I set a breakpoint for DETECTED_MISSING_CONSTRAINTS and find that execution is halting on myPopup.runModal() in this code:

func happyAlert(message: String, info: String) {
        let myPopup: NSAlert = NSAlert()
        myPopup.messageText = message
        myPopup.informativeText = info
        myPopup.alertStyle = NSAlertStyle.informational
        myPopup.addButton(withTitle: "OK")

This alert informs with user that the image has passed or not passed various validation checks.

What used to happen is that the image was selected, the NSOpenPanel dismissed and the alert appeared without any problems.

Now I get the error about constraints for an NSTextField, but I don’t understand why they would be involved here, especially since xCode does not flag any autolayout issues with the underlying view.

Can anyone explain what might be going on and/or a strategy for further debugging? My experience is limited and I am baffled.