apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 986 forks source link

Please remove org_apache_cordova_UIView_Extension because it isn't necessary since iOS 8. #1399

Open hbordersTwitch opened 2 months ago

hbordersTwitch commented 2 months ago

Feature Request

Cordova contains org_apache_cordova_UIView_Extension in CDVPlugin.h:

@interface UIView (org_apache_cordova_UIView_Extension)

@property (nonatomic, weak) UIScrollView* scrollView;

@end

with an implementation in CDVPlugin.m:

@implementation UIView (org_apache_cordova_UIView_Extension)

@dynamic scrollView;

- (UIScrollView*)scrollView
{
    SEL scrollViewSelector = NSSelectorFromString(@"scrollView");

    if ([self respondsToSelector:scrollViewSelector]) {
        return ((id (*)(id, SEL))objc_msgSend)(self, scrollViewSelector);
    }

    return nil;
}

@end

It appears Cordova only uses the scrollView property on WKWebView instances, and WKWebView has exposed a scrollView property since iOS8, and Cordova's iOS Platform Guide says iOS 11 is the minimum version required for devices to run Cordova. Thus, this extension and artificial property is unnecessary.

Motivation Behind Feature

Apps integrating Cordova with Swift codebases will not compile if Swift classes feature scrollView members in UIView subclasses with visibility less than public. Integrating Cordova would be easier without this extension.

Alternatives or Workarounds

Integrators can manually delete the @interface from the public header file to avoid compilation issues.