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 版本和其他资源链接(包括发布版和测试版)。

解决方法

这是非常困难但有效的解决方法。 将storyboardXib中的所有UITextView替换为纯代码版本。

<小时/>

请注意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/58701116/

相关文章:

ios - 如何仅在 swiftUI 中将拖动手势限制到特定帧

ios - 从程序执行 .addSubview 到 View 实际出现的意外延迟 - Swift

xcode - 沙箱无法访问本地套接字

objective-c - 调用initWithCoder后,IBOutlet为零

iphone - iPhone 中的 Http 请求/响应 API

ios - UIImagePickerController - 在相机 View 中选择保存的图像

ios - UINavigationBar中的UISearchBar不能改变高度?

swift - 获取 NSLayoutConstraint 标识符不适用于 topAnchor

ios 覆盖drawRect后设置RoundCorner不起作用,但正常的UIView没问题

android - 如何将 "Flutter for Web"转换为 "Flutter for Mobile"?