tombenner / nui

Style iOS apps with a stylesheet, similar to CSS
MIT License
3.76k stars 462 forks source link

override_didMoveToWindow infinite loop when running Xcode 12 and iOS 14 #381

Open fpaaske opened 4 years ago

fpaaske commented 4 years ago

This could be related to #91, #154 or #275, but I'm not sure. It works fine on Xcode 12 and iOS 13.5.

image

MichaelYNWA commented 4 years ago

I have the same problem xcode12.1 ios14.1 How to resolve? It works fine on Xcode 12.1 and iOS 13.5.1.

截屏2020-11-09 下午2 37 38
nicogonza commented 4 years ago

We had the same crash detailed above. This apple forum thread explains what is going on here.

We maintain our own fork since this library is no longer being maintained. You can see the changes we made to work around this crash here.

mackworth commented 3 years ago

Thank you!

chenxGen commented 3 years ago

Try to replace override_didMoveToWindow method in UIView+NUI.m with code below, it works for me.

- (void)override_didMoveToWindow
{
    if (self.class != [UIView class]) {
        Method currentMethod = class_getInstanceMethod(self.class, @selector(override_didMoveToWindow));
        Method expectedMethod = class_getInstanceMethod([UIView class], @selector(override_didMoveToWindow));
        if (currentMethod && expectedMethod) {
            /// Both subclass and UIView override method override_didMoveToWindow,
            /// In this case, just invoke method of UIView(original implementation of `didMoveToWindow`).
            if (currentMethod != expectedMethod) {
                ((void (*)(id, Method))method_invoke)(self, expectedMethod);
                return;
            }
        }
    }

    if (!self.isNUIApplied) {
        [self applyNUI];
    }
    [self override_didMoveToWindow];
}