Skip to content

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

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

Closed
jmagman opened this issue May 2, 2023 · 8 comments · Fixed by flutter/packages#8564
Labels
p: webview The WebView plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@jmagman
Copy link
Member

jmagman commented May 2, 2023

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

@jmagman jmagman added platform-ios iOS applications specifically p: webview The WebView plugin package flutter/packages repository. See also p: labels. labels May 2, 2023
@jmagman jmagman changed the title [webview_flutter_wkwebview] -[WKPreferences javaScriptEnabled] is deprecated in iOS 14 [webview_flutter_wkwebview] -[WKPreferences javaScriptEnabled] is deprecated in iOS 14 May 2, 2023
@stuartmorgan-g stuartmorgan-g added the P2 Important issues not at the top of the work list label May 2, 2023
@stuartmorgan-g
Copy link
Contributor

See discussion in #128714 about how we might go about addressing this in the current Dart/native mirroring structure.

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Jul 8, 2023
@jmagman
Copy link
Member Author

jmagman commented Aug 16, 2024

@bparrishMines @stuartmorgan Is there some way we can unblock this so we can increase the xcode-analyze minimum version? Should I exclude webview_flutter_wkwebview from that check?
flutter/packages#7431

@stuartmorgan-g
Copy link
Contributor

We don't have to remove the whole plugin to unblock the check, we could just #pragma-suppress the specific warning if it's blocking us.

@jmagman
Copy link
Member Author

jmagman commented Aug 20, 2024

Oh right... 🤦‍♀️

@bparrishMines
Copy link
Contributor

@jmagman It looks like WKWebpagePreferences requires iOS 13 and webview_flutter_wkwebview still has a minimum of 12. I think it would be easiest to switch the value we set once the minimum of webview_flutter_wkwebview is moved up to 13 and we can just use the #pragma until then.

@jmagman
Copy link
Member Author

jmagman commented Aug 26, 2024

we can just use the #pragma until then.

Thanks for taking care of that, @stuartmorgan! flutter/packages#6221

@stuartmorgan-g
Copy link
Contributor

Hah, I wrote that part of the PR so long ago I forgot about it. The Flutter macOS template project apparently has stricter checks than iOS, so I had to fix up some things when I added macOS support.

auto-submit bot pushed a commit to flutter/packages that referenced this issue Aug 29, 2024
Bump Xcode analyze minimum check version iOS 13 -> iOS 14 and macOS 12.3 -> macOS 13.

- Hit StoreKit2 deprecations. Exclude `in_app_purchase_storekit` to work around StoreKit 1 deprecation warnings.  Added a TODO to remove the exclusion when StoreKit2 is adopted (this should happen in the next few weeks) flutter/flutter#116383.
- Hit flutter/flutter#153587, fixed in #7513
- Hit flutter/flutter#125901 which was `#pragma`'d out in #6221

See related flutter/plugins#5778 and flutter/flutter#102835
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p: webview The WebView plugin P2 Important issues not at the top of the work list package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy