Assertion failure in UITextView _firstBaselineOffsetFromTop

I was learning about the view debugger in Xcode and capturing the view hierarchy with Debug > View Debugging > Capture View Hierarchy. However when I tried it in my app I got the following error:

Assertion failure in -[UITextView _firstBaselineOffsetFromTop], /BuildRoot/Library/Caches/

  • How to find path of Bridging-Header.h - Swift, Xcode
  • Xcode 8 recommend me to change the min iOS Deployment Target from 7.1 to 8.0
  • UITableViewCell reusability issue. Modifying one cell is affecting others
  • How can I resolve “Error: No developer directory found at /Developer”?
  • XCODE 6 (6A313) Compile Error using Outlets
  • UITextfields returning null in iOS 6
  • I could reproduce this in the following simple project:

    import UIKit
    class ViewController: UIViewController {
        override func viewDidLoad() {
            let myTextView = UITextView()
            myTextView.frame = CGRect(x: 50, y: 50, width: 200, height: 100)
            myTextView.text = "This is a test."

    I saw here that it could be caused by not using auto layout. Is this really a bug that we have to wait for a fix? Is there a Swift workaround?


    The suggested duplicate looks like the same issue I am having. However, unlike that question, I am asking for a Swift workaround. The “answer” to that question was just a link (the same link that I already had above). I am voting to close the other way.

    Solutions Collect From Internet About “Assertion failure in UITextView _firstBaselineOffsetFromTop”

    Note do this in DEBUG builds only

    A workaround to resolve this issue. Keep below category in your project. It worked for me.

    @interface UITextView(MYTextView)
    @implementation UITextView (MYTextView)
    - (void)_firstBaselineOffsetFromTop {
    - (void)_baselineOffsetFromBottom {

    For swift

    extension UITextView {
        func _firstBaselineOffsetFromTop() {
        func _baselineOffsetFromBottom() {