恭喜
新版 Xcode (11.2.1) 现已推出,这是解决此问题的最佳方法。
解决方法
@Mojtaba Hosseini 我提出的解决方案来自我身边对 StackOverflow 开发人员的帮助和参与。你、我和这里的所有其他开发者都已经知道,当苹果宣布新版本时,这个问题就会消失。
但除此之外
上述解决方案肯定被 Apple Review 接受,因为根本不涉及私有 API。这种方法非常类似于像
这样的创建属性
@interface UITextView(布局)
或者
UITextView+Layout.h
因此,当您创建属性时,您将直接使用 APPLE 私有组件并根据您的依赖或要求重新调制它们。
简单的例子是 AMFNetworking 类
- (void)setImageWithURL:(NSURL *)url {
[self setImageWithURL:url placeholderImage:nil];
}
希望我已经完成了指控
下面的答案只是我方面的一些帮助,以使开发人员能够继续开发,因为我们最初建议开发人员回滚 Xcode。再次下载 8 GB Xcode 是一种不好的做法,因为我们都知道新版本的 Xcode 即将发布。
虽然它已在 Xcode 11.2.1 中修复,但我为 Xcode 11.2 提供了一种解决方案,您可以通过它摆脱这种崩溃:
*** 由于未捕获的异常“NSInvalidUnarchiveOperationException”而终止应用程序,原因:“无法实例化名为 _UITextLayoutView 的类,因为找不到名为 _UITextLayoutView 的类;该类需要在源代码中定义或从库中链接(确保该类是正确目标的一部分)'
解决方案
转到构建设置搜索“DEAD_CODE_STRIPPING”并将其设置为 NO
DEAD_CODE_STRIPPING = NO
那么
创建文件 UITextViewWorkaround
UITextViewWorkaround.h
#import <Foundation/Foundation.h>
@interface UITextViewWorkaround : NSObject
+ (void)executeWorkaround;
@end
UITextViewWorkaround.m
#import "UITextViewWorkaround.h"
#import <objc/runtime.h>
@implementation UITextViewWorkaround
+ (void)executeWorkaround {
if (@available(iOS 13.2, *)) {
}
else {
const char *className = "_UITextLayoutView";
Class cls = objc_getClass(className);
if (cls == nil) {
cls = objc_allocateClassPair([UIView class], className, 0);
objc_registerClassPair(cls);
#if DEBUG
printf("added %s dynamically\n", className);
#endif
}
}
}
@end
在应用委托中执行它
#import "UITextViewWorkaround.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[UITextViewWorkaround executeWorkaround];
return yes;
}
编译代码,您将拥有一个正在运行的应用程序:)