Peter Wiley
Peter Wiley

Reputation: 840

New auto layout errors with Xcode 8.1

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")
    myPopup.runModal()
}

This alert informs the 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.

Upvotes: 36

Views: 2594

Answers (1)

AD Progress
AD Progress

Reputation: 5146

Check your view hierarchy in the interface builder it might be that the textField sits on top of everything and Xcode is trying to set the constraints for it. Otherwise, perhaps add some screenshots of what is going on in your storyboards. Have you tried setting the textField's in question width and height from = to >= the value set? I had issues in the past where such a silly setting has sorted a bug similar to this one.

Upvotes: 1

Related Questions