Xcode 10 Interface Builder regression with collection views

Originator:atomicbird
Number:rdar://44805560 Date Originated:2018-09-26
Status:Open Resolved:
Product:Xcode Product Version:10.0 (10A255)
Classification:Serious Bug Reproducible:Yes
 
Summary:

When using a UICollectionView where a cell contains a UIStackView, Xcode 10 flags the layout as ambiguous. No combination of constraints will resolve the ambiguity. The layout works as expected when the app runs, and Xcode 9 does not flag the layout as ambiguous.

Steps to Reproduce:

[Minimal sample project attached.]

1. Create a new project using Xcode's Single View App template
2. In Main.storyboard, add a collection view to the UI. Constrain it to fill its parent view.
3. Change the collection view's single cell size to an arbitrary size. It doesn't matter what it is but a larger one makes the following steps easier.
4. Add a UIStackView to the collection view cell. Constrain it to fill the cell content (zero boundary on all sides).
5. Add a single UILabel to the stack view. The stack view resizes it to fill the stack, which is fine.

Expected Results:

If the stack view is constrained to fill the cell, the layout would not be ambiguous. For example constraining leading, trailing, top, and bottom sides of the stack view to be zero pixels from the corresponding edges of the cell.

Actual Results:

In Xcode 9.4.1 and when running the app, it works as expected.

Xcode 10 (10A255) reports that the layout is ambiguous. Errors are:

* Stack view needs constraints for its X position or width.
* Stack view needs constraints for its Y position or height.

All of these should be clear from the constraints.

Version/Build:

Xcode 10 (10A255)
macOS 10.13.6 (17G65)

Configuration:

In the sample project, Main.storyboard contains two view controllers. One is configured as described above. The other uses a table view controller with a similar arrangement of stack view and label.

When opened in Xcode 9.4.1, no layout errors are reported.
When opened in Xcode 10, the layout is ambiguous and cannot be fixed by any combination of constraints.

Sample project: http://atomicbird.com/share/CollectionViewStack-SisyZbIsxp.zip

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!