Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 675
Peter Wiley Avatar asked Nov 03 '16 15:11

Peter Wiley


People also ask

How do I enable auto layout in Xcode?

Create a new Xcode project. Select Single view app and name it AutoLayout. Leave the defaults unchecked: Use core data.

How do I turn off auto layout in Xcode?

Disable Auto Layout by unchecking the Use Autolayout (sic) or Use Auto Layout box in Xcode's File Inspector. This option appears for both iOS and OS X projects.


1 Answers

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.

like image 172
AD Progress Avatar answered Sep 25 '22 23:09

AD Progress