-UIViewShowAlignmentRects YES Crashes with UIVisualEffectView

Originator:keith
Number:rdar://35029997 Date Originated:17 Oct 2017
Status:Open Resolved:
Product:Xcode Product Version:9.0.1
Classification:Bug Reproducible:Always
 
Area:
UIKit

Summary:
Adding the launch argument -UIViewShowAlignmentRects YES to debug alignment rectangles causes a crash if there is a UIViewEffectView in the view hierarchy. This happens for example with a plain `UIViewController` embedded in a navigation controller.

Steps to Reproduce:

1. Create a new Xcode project using the single view app template.
2. Modify the storyboard to embed the view controller in a navigation controller.
3. Edit the scheme to add and enable the following launch argument to the run action:
    -UIViewShowAlignmentRects YES
4. Build and run on a simulator

Expected Results:

The alignment rectangles of the views are displayed in yellow.

Actual Results:

Crashes with following console message:

2017-10-17 16:46:24.425431+0100 Alignment[24633:2704672] [LayoutConstraints] UIViewShowAlignmentRects is ON
2017-10-17 16:46:24.505213+0100 Alignment[24633:2704672] *** Assertion failure in -[UIVisualEffectView _addSubview:positioned:relativeTo:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3698.16.15/UIVisualEffectView.m:1464
2017-10-17 16:46:24.512331+0100 Alignment[24633:2704672] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ' > has been added as a subview to  >. Do not add subviews directly to the visual effect view itself, instead add them to the -contentView.'

Version/Build:
iOS 11.0.1 (15A8401)
Xcode Version 9.0.1 (9A1004)

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!