从Xcode 11.1升级到Xcode 11.2后,由于_UITextLayoutView,应用程序崩溃 [英] After upgrading to Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView

查看:234
本文介绍了从Xcode 11.1升级到Xcode 11.2后,由于_UITextLayoutView,应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

***由于未捕获的异常'NSInvalidUnarchiveOperationException'而终止应用程序,原因:'无法实例化名为_UITextLayoutView的类,因为未找到名为_UITextLayoutView的类;该类需要在源代码中定义或从库中链接(确保该类是正确目标的一部分)'

*** 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?

推荐答案

祝贺

新版本的Xcode(11.2.1)现在可用,这是摆脱此问题的最佳方法.

The New version of Xcode (11.2.1) is available now which is the best way to get rid off this issue.

解决方法

@Mojtaba Hosseini,我提出的解决方案来自于Stackoverflow的帮助和我的同伴开发人员的参与.您,我以及此处的所有其他开发人员已经知道,当Apple宣布新版本时,此问题将消失.

@Mojtaba Hosseini the solution I proposed was from the help and the participation from my side to my fellow developers over StackOverflow. You, me and all the rest of the developer here already know that when the new version is announced by Apple, this issue will be gone.

但要紧紧抓住一切

由于完全不涉及私有API,因此上述解决方案已被Apple Review接受.这种方法与

The solution aforementioned was definitely accepted by Apple Review as there is no private API involved at all. This approach is very similar to the creating property like

@interface UITextView(布局)

@interface UITextView (Layout)

UITextView + Layout.h

UITextView+Layout.h

因此,当您创建属性时,您将直接使用APPLE私有组件并根据您的需要或要求对其进行重新调制.

So when you are creating property you are directly using APPLE Private Components and re-moduling them as per you depends or requirement.

简单的例子是AMFNetworking类

The Simple Example is AMFNetworking classes

- (void)setImageWithURL:(NSURL *)url {
    [self setImageWithURL:url placeholderImage:nil];
}

希望我已经完成了指控

下面的答案只是我方面的一些帮助,可以使开发人员继续开发,就像您最初建议开发人员回滚Xcode一样.再次下载8 GB Xcode是一个不好的做法,因为我们都知道Xcode的新版本将很快发布.

The answer below was just some help from my side to enable developer to continue developing as you we initially proposed developer to roll back Xcode. This was a bad practice to download 8 GB Xcode again since we all know that the new version of Xcode will be released soon.

虽然Xcode 11.2.1已修复该问题,但我为Xcode 11.2提供了一种解决方案,您可以摆脱这种崩溃:

While it is fixed in Xcode 11.2.1, I got one solution for Xcode 11.2 by which you can get rid off this crash:

***由于未捕获的异常'NSInvalidUnarchiveOperationException'而终止应用程序,原因:'无法实例化名为_UITextLayoutView的类,因为未找到名为_UITextLayoutView的类;该类需要在源代码中定义或从库中链接(确保该类是正确目标的一部分)'

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

解决方案

转到构建设置"搜索"DEAD_CODE_STRIPPING"并将其设置为否"

Go to the Build Setting search for "DEAD_CODE_STRIPPING" and set it to NO

DEAD_CODE_STRIPPING = NO

然后

创建文件UITextViewWorkaround

create files 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

在应用程序委托中执行

execute it in the app delegate

#import "UITextViewWorkaround.h"

        - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
            // Override point for customization after application launch.

            [UITextViewWorkaround executeWorkaround];
    return yes;
    }

编译代码,您将拥有一个正在运行的应用程序:)

Compile the code and you will have a running app :)

这篇关于从Xcode 11.1升级到Xcode 11.2后,由于_UITextLayoutView,应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆