Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCode11.4 模拟器iPhone8 Demo闪退 Thread 1: EXC_BAD_ACCESS #16

Open
dosedo opened this issue Apr 21, 2020 · 5 comments
Open

XCode11.4 模拟器iPhone8 Demo闪退 Thread 1: EXC_BAD_ACCESS #16

dosedo opened this issue Apr 21, 2020 · 5 comments

Comments

@dosedo
Copy link

dosedo commented Apr 21, 2020

xcode11.4, 启动就会闪退。 经过试验,确定是UILabel+NERChainable 中的color属性问题。

只要label调用color 就会闪退。直接报内存泄漏。

把color的名字换一个,就可以运行了。但项目使用color处较多,期望朋友看到帮忙查查问题。

图片

@zzl4321
Copy link

zzl4321 commented Apr 23, 2020

你也遇到这问题了?

@JiXuGanLu
Copy link

JiXuGanLu commented Apr 27, 2020

暂时可以通过关闭Main Thread Checker服务解决。该问题应该是仅发生在iOS13.4及以上的模拟器和真机,好在真机只是在连Xcode调试的时候才会因为Main Thread Checker崩溃,单独运行没有问题,所以对用户没什么影响。具体Main Thread Checker在这个地方为什么会出问题和更好的解决方案还没搞清楚。
20200427153726

@danteliu
Copy link

遇到同样的问题 xcode 11.5 真机13.5

@chiyun1
Copy link

chiyun1 commented May 8, 2021

image

Main Thread Checker开启之后,不知道为什么会导致UIKit里UILabel一个废弃的方法被引入进来。这个方法的名字也是color。出问题时就是color实际上执行了这个方法,然后用返回的UIColor类型的值去当作block执行继而导致了崩溃。 不过同样没找到好的解决办法,项目里用color也不少,改起来真麻烦。

@chiyun1
Copy link

chiyun1 commented May 8, 2021

找到一个打补丁的办法,在项目中添加上下面的Category代码。

@interface UILabel (fixColorBug)

@end
@implementation UILabel(fixColorBug)

+ (void)load
{
    Method method = class_getInstanceMethod([self class], @selector(color));
    Method methodNew = class_getInstanceMethod([self class], @selector(fcb_color));
    method_exchangeImplementations(method, methodNew);
}

- (id)fcb_color{
    id color = [self fcb_color];
    if (color == nil || [color isKindOfClass:[UIColor class]]) {
        //deprecated method
        return ^(id color){
            self.textColor = Color(color);
            return self;
        };
    }else{
        return color;
    }
}
@end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants