The visual debugger fails because of an assertion in UIKit's UITextView when auto layout is not used

Originator:steipete
Number:rdar://25311044 Date Originated:23-Mar-2016 10:12 AM
Status:Closed Resolved:
Product:Developer Tools Product Version:9.3
Classification:Other Bug Reproducible:Always
 
Summary:
The visual debugger fails because of an assertion in UIKit's UITextView when auto layout is not used.

Steps to Reproduce:
Run sample in Xcode 7.3. Select view debugger. Observe assertion in the log and no working view debugger.

2016-03-23 10:05:17.963 AutoLayoutViewDebuggingIssue[83786:1782898] *** Assertion failure in -[UITextView _firstBaselineOffsetFromTop], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UITextView.m:1683

Expected Results:
View debugger should work. Nothing should throw up in the log.

Actual Results:
Sadness. No view debugger. Me going back to Reveal, then getting curious and spending an hour on this radar :)

Regression:
This used to work, could be a regression in Xcode 7.3 OR in UIKit 9.3? I’ve checked my decompiles for UIKit and it doesn’t seem like it’s a recent UIKit change, so pretty sure it’s a recent Xcode change instead.

Notes:
See my workaround in ViewController.m via adding useless constraints to satisfy the check in the method that asserts. Rather not do that but don’t see another way.

Comments

Fixed in iOS 10b1/Xcode 8b1

Not fixed in Xcode 7.3.1 GM Seed.

By adigitalknight at April 21, 2016, 8:44 a.m. (reply...)

Workaround from steipete is:

    if ([NSLayoutConstraint respondsToSelector:@selector(activateConstraints:)]) {
        TEXTVIEWNAME.translatesAutoresizingMaskIntoConstraints = NO;
        [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[TEXTVIEWNAME]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(TEXTVIEWNAME)]];
    }
By adigitalknight at March 31, 2016, 7:05 a.m. (reply...)

Sample: http://cl.ly/3H473S0w3s2q


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!