Skip to content

[webview_flutter_wkwebview] -[WKPreferences javaScriptEnabled] is deprecated in iOS 14 #125901

Closed
flutter/packages
#8564
@jmagman

Description

@jmagman

webview_flutter_wkwebview is using an API that was deprecated in iOS 14. Use an @availability check to use the non-deprecated property, and fall back to the old one on < 14.

  [[self preferencesForIdentifier:identifier] setJavaScriptEnabled:enabled.boolValue];

https://github.com/flutter/packages/blob/c90dd9834ebfd3d9b06f5f99dae1dd7652de6053/packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFPreferencesHostApi.m#L44

Deprecation says Use WKWebpagePreferences.allowsContentJavaScript to disable content JavaScript on a per-navigation basis. I don't think WKWebpagePreferences is currently created in the plugin.

FWFPreferencesHostApi.m:44:47: error: 'setJavaScriptEnabled:' is deprecated: first deprecated in iOS 14.0 - Use WKWebpagePreferences.allowsContentJavaScript to disable content JavaScript on a per-navigation basis [-Werror,-Wdeprecated-declarations]
  [[self preferencesForIdentifier:identifier] setJavaScriptEnabled:enabled.boolValue];
                                              ^
In module 'WebKit' imported from FWFPreferencesHostApi.h:6:
WKPreferences.h:92:28: note: property 'javaScriptEnabled' is declared deprecated here
@property (nonatomic) BOOL javaScriptEnabled API_DEPRECATED("Use WKWebpagePreferences.allowsContentJavaScript to disable content JavaScript on a per-navigation basis", macos(10.10, 11.0), ios(8.0, 14.0));

You can see this by running:

$ dart run script/tool/bin/flutter_plugin_tools.dart xcode-analyze "--ios-min-version=14.0" --ios
    args: ["xcode-analyze", "--ios", "--ios-min-version=14.0"]

https://github.com/flutter/packages/blob/c90dd9834ebfd3d9b06f5f99dae1dd7652de6053/.ci/targets/ios_platform_tests.yaml#L15

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions