After upgrading to Xcode 11.2 from Xcode 11.1, app

2020-01-24 10:11发布

After upgrading to Xcode 11.2 from Xcode 11.1 my app crashes:

*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named _UITextLayoutView because no class named _UITextLayoutView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)'

Why is this happening? How can I prevent this crash?

15条回答
时光不老,我们不散
2楼-- · 2020-01-24 11:12

I had the same issue I just upgraded my Xcode 11.2 to 11.2.1 it worked fine.

After upgrade I have tested the same on iOs 13 and iOS 12 and it was working fine.

查看更多
The star\"
3楼-- · 2020-01-24 11:14

Improving on @garafajon answer. For me it works in most cases.

///Substitute class for _UITextLayoutView bug
class FixedTextView: UITextView {
    required init?(coder: NSCoder) {
        if #available(iOS 13.2, *) {
            super.init(coder: coder)
        }
        else {
            super.init(frame: .zero, textContainer: nil)
            self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
            self.contentMode = .scaleToFill

            self.isScrollEnabled = false   // causes expanding height

            // Auto Layout
            self.translatesAutoresizingMaskIntoConstraints = false
            self.font = UIFont(name: "HelveticaNeue", size: 18)
        }
    }
}
查看更多
SAY GOODBYE
4楼-- · 2020-01-24 11:15

It is a bug with Xcode 11.2. Subclassed Textviews are crashing on all devices not having the neweset iOS build (13.2) installed. You probably better not build a release with that build.

You can now:

  • downgrade Xcode to 11.1 or
  • upgrade your device to iOS 13.2
查看更多
登录 后发表回答