ios - 从 Xcode 11.1 升级到 Xcode 11.2 后,应用程序因 _UITextLayoutView 崩溃

标签 ios swift xcode uitextview xcode11

从 Xcode 11.1 升级到 Xcode 11.2 后,我的应用程序崩溃了:

*** 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)'

为什么会发生这种情况?我怎样才能防止这种崩溃?

最佳答案

更新:已修复! 🎉🎊

唯一的解决方案是更新

这个bugfixed在 Xcode 11.2.1 中。所以你可以download and use it from here.

Storyboards containing a UITextView will no longer cause the app to crash on operating system versions earlier than iOS 13.2, tvOS 13.2, or macOS 10.15.2. (56808566, 56873523)

<小时/>

Apple 已于 2019 年 11 月 5 日弃用 Xcode 11.2

如果您尝试将使用 Xcode 11.2 构建的应用程序提交到 AppStore,您将被拒绝:

App Store Connect 操作警告

WARNING ITMS-90703: "Deprecated Xcode Build. Due to resolved app archives issues, we have deprecated Xcode 11.2 on November 5, 2019. Download Xcode 11.2.1 or newer, rebuild your app and resubmit."

因此,使用 Xcode 11.2 完成的所有解决方法都是无用

<小时/>

这是 Xcode 11.2 的错误,已在 Xcode 11.2.1 中修复。

解决方案

回滚到以前的 Xcode release 版本: 回滚不再是一个选项,AppStore 将拒绝使用低于 11.2.1 的 Xcode 进行任何构建 take a look at this

https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_11.1/Xcode_11.1.xip

请注意您应该使用 Safari 来下载它,并且必须首先login to Apple developer portal .

您可以在 https://developer.apple.com/download/more 找到所有其他 Xcode 版本和其他资源链接(包括发布版和测试版)。

解决方法

这是非常困难但有效的解决方法。 全部替换UITextView StoryboardXib中的纯代码版本。

<小时/>

请注意bug is found and fixed by Apple

Fixed

同样早些时候,the bug已被Apple Staff edford确认

Confirmation

<小时/>

对于使用 iOS 13.2 且无法再使用 Xcode 11.1 的用户:

  1. 将 macOS 更新到 10.15.1 或更高版本
  2. 安装 Xcode 11.2.1 或更高版本
  3. 现在应该可以在更新后的设备上运行了。

对于那些有 Storyboard的人:

  1. 子类UITextView
  2. 将其分配给所有人 UITextView对象
  3. 不要忘记更新子类化中可能丢失的任何属性更改。

对于那些熟悉方法调配(Objc 和动态行为)的人

前往@aftab muhammed khan answer for Objective-C和@MikRo answer for Swift adapted version

别再这样做了:

即使最后两个混合解决方法没有使用 Apple 私有(private) API,它们也会在 AppStore 中被拒绝,因为 Apple will not accept builds with Xcode versions under 11.2.1 !

再一次:

Apple 已于 2019 年 11 月 5 日弃用 Xcode 11.2

关于ios - 从 Xcode 11.1 升级到 Xcode 11.2 后,应用程序因 _UITextLayoutView 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58666605/

相关文章:

ios - 除非我禁用自动调整 subview ,否则 UIPickerView 会错误地显示值

ios - Swift 4 - 通过 UIActivityViewController 共享位置

json - 快速解析响应时出现问题?

iphone - 在运行后台线程时释放对象时崩溃

ios - 将 MKMapView 缩放级别设置为局部

swift - 计时器不会调用选择器函数

ios - MMDrawerController 无法关闭抽屉

Xcode 菜单项 Editor/Add Model Version... 丢失

ios - 自定义字体显示在 iOS 模拟器上,但不显示在 Storyboard 上

iphone - 使用 OpenCV 和 LBP 在 iPhone 上进行人脸检测