13

I'm working in Xcode 10 and am getting some errors when trying to add some pretty simple constraints to my view.

I have a UICollectionViewCell that I'm adding a UIStackView to. I size the UIStackView to fill the cell and set the top, bottom, left, and right constraints to the Safe Area.

I used to be able to do this in Xcode 9 without error, however, it now gives me an error that I need to specify the X Position or Width and the Y Position or Height. Even when I let the interface builder add the missing constraints (Center X and Center Y) it gives the same error. I feel like this is a bug in Xcode 10, but if there are new iOS 12 requirements for constraints I don't know about I'd appreciate some help with them.

If I ignore the erroneous constraints and run the app the view does not show up properly.

enter image description here

enter image description here

enter image description here

UPDATE

I definitely think this is a bug. Notice in the screenshot below, even though I have subviews in the stack view, the errors do not go away. Also, when I add static padding to the top, left, bottom, and right it does not show properly in the layout, however it does layout properly when I run the app.

enter image description here

tentmaking
  • 2,076
  • 4
  • 30
  • 53

1 Answers1

12

This is, indeed, a bug in Xcode 10. To resolve this issue, embed the stack view in another view, which has the same constraints as the stack view before:

view structure

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223