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

xcode 16 beta3 - ambiguous use of 'evaluateJavaScript(_:completionHandler:_)' build error #2221

Closed
2 tasks done
Hannah-mayhew1 opened this issue Jul 12, 2024 · 60 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@Hannah-mayhew1
Copy link

Hannah-mayhew1 commented Jul 12, 2024

  • I have read the Getting Started section
  • I have already searched for the same problem

Environment

Technology Version
Flutter version 3.22.2
Plugin version 6.0.0
Android version x
iOS version 18
macOS version x
Xcode version 16 beta 3
Google Chrome version x

Device information:

Description

Expected behavior:
Build successful

Current behavior:
Screenshot 2024-07-12 at 16 43 55

Notes
This is specifically an incompatibility with xcode16 and not iOS18. Xcode 16 is needed to install iOS18 simulators, however iOS18 simulators will run on xcode15. I was able to bypass the issue by rolling back xcode16 to 15.4 and running iOS18 there.

@Hannah-mayhew1 Hannah-mayhew1 added the bug Something isn't working label Jul 12, 2024
Copy link

👋 @Hannah-mayhew1

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

@Hannah-mayhew1
Copy link
Author

Linked issue

@allentown521
Copy link

same here

@dn1t
Copy link

dn1t commented Jul 20, 2024

Same error also occurs in flutter_inappwebview_macos (macOS 15 Beta, Xcode 16 Beta 3)

@Mounix99
Copy link

+1

@frapeti
Copy link

frapeti commented Jul 21, 2024

+1

Broken build on iOS

@Hannah-mayhew1
Copy link
Author

FYI, this is specifically an incompatibility with xcode16 and not iOS18. Xcode 16 is needed to install iOS18 simulators, however iOS18 simulators will run on xcode15. I was able to bypass the issue by rolling back xcode16 to 15.4 and running iOS18 there.

@allentown521
Copy link

FYI, this is specifically an incompatibility with xcode16 and not iOS18. Xcode 16 is needed to install iOS18 simulators, however iOS18 simulators will run on xcode15. I was able to bypass the issue by rolling back xcode16 to 15.4 and running iOS18 there.

Yes, this is a temporary solution, next year the appstore will force the use of xcode16, will still face this problem, the library has been more than half a year without merging code!

@aokisinn
Copy link

Is this being fixed?

@ConnorDykes
Copy link

I updated Mac OS to beta versions and it won't let me downgrade to Xcode 15.4 now. I am stuck with Xcode 16, Any help would be appreciated.

@Mounix99
Copy link

Mounix99 commented Aug 7, 2024

@ConnorDykes this should work

dependency_overrides:
  url_launcher_ios: 6.3.1

@landonmr
Copy link

landonmr commented Aug 14, 2024

same error, the dependency override didn't work for me, any update on this issue? Package doesn't seem compatible with xcode 16

@mubahood
Copy link

I clicked on the error, and I deleted one like this, then it worked!

 public override func evaluateJavaScript(_ javaScriptString: String, completionHandler: ((Any?, Error?) -> Void)? = nil) {
        if let applePayAPIEnabled = options?.applePayAPIEnabled, applePayAPIEnabled {
            if let completionHandler = completionHandler {
                completionHandler(nil, nil)
            }
            return
        }
        super.evaluateJavaScript(javaScriptString, completionHandler: completionHandler)
    } 

@ConnorDykes
Copy link

ConnorDykes commented Aug 28, 2024

just updated to beta 6 and im getting this issue again, I had to edit the funciton to look like this:

open override func evaluateJavaScript(_ javaScriptString: String, completionHandler: (@mainactor (Any?, Error?) -> Void)? = nil) {
if let applePayAPIEnabled = options?.applePayAPIEnabled, applePayAPIEnabled {
if let completionHandle = completionHandler {
completionHandler?(nil, nil)
}
return
}
super.evaluateJavaScript(javaScriptString, completionHandler: completionHandler)
}

the trick was adding the ? onto   completionHandler?(nil, nil)

it will build from Xcode directly but not VScode

@tnitsiri
Copy link

#2201 (comment)

@gabielchong
Copy link

+1

@tinaroh
Copy link

tinaroh commented Sep 13, 2024

I noticed someone put out a fix for this, which is to update the signature of evaluateJavaScript #2274

For now I'm overriding with it in pubspec.yaml:

dependency_overrides:
  flutter_inappwebview_ios:
    git:
      url: https://github.com/pichillilorenzo/flutter_inappwebview.git
      ref: 27fd339172572fe1b16cdcdae235b2a88f432e3c
      path: flutter_inappwebview_ios

@andychucs
Copy link

andychucs commented Sep 13, 2024

Just like what tinaroh commented.

I make a little different changes based on other pr. I keep the override function evaluateJavaScript as public instead of delete or change as open.

Also can use like following:

  flutter_inappwebview_ios:
    git:
      url: https://github.com/andychucs/flutter_inappwebview.git
      ref: master
      path: flutter_inappwebview_ios

@qwertylolman
Copy link

the xcode16 release is available, so this issue is a kind of critical. any updates?

@pedroculque
Copy link

Same problem here, any updates?

@nabiarshad
Copy link

same issue after updating to Mac OS sequoia.
Xcode Version 16.0 (16A242d)

@Daniel-eXeX
Copy link

Seconding this. I'm now encountering this issue after XCode just auto-updated. Until a fix comes out, it appears that downgrading to XCode 15.4 will work around the issue.

For those mentioning the fork made by andychucs, it doesn't seem like it works (or I set it up wrong). I still got the exception even after adding the fork as a dependency override.

@qwertylolman
Copy link

downgrading to XCode 15.4 will work around the issue.

are you able to downgrade the xcode? i cannot, as my macos also updated to sequoia. it just shows an error 'in order to use xcode you need to update to the latest version'

@Daniel-eXeX
Copy link

are you able to downgrade the xcode? i cannot, as my macos also updated to sequoia. it just shows an error 'in order to use xcode you need to update to the latest version'

I was about to come back to comment on this. I was talking to a colleague who said that he could not downgrade because he'd updated his OS version. If you've already upgraded it, then you'll need another solution.

(As such, I'm now trying to get things working with XCode 16.0 again... 15.4 is a very temporary solution)

@rania-run
Copy link

rania-run commented Sep 18, 2024

I have the same issue, this temporary solution works for me, thank you 🚀

Just like what tinaroh commented.

I make a little different changes based on other pr. I keep the override function evaluateJavaScript as public instead of delete or change as open.

Also can use like following:

  flutter_inappwebview_ios:
    git:
      url: https://github.com/andychucs/flutter_inappwebview.git
      ref: master
      path: flutter_inappwebview_ios

@scriptam
Copy link

For those looking for a fast workaround for Xcode 16.0 (16A242d), the following is worth a consideration: #2274 (comment)

Credit and thanks go to @andychucs

Add the following to your pubspec.yaml

dependencies:
  # rest of your dependencies ...
  flutter_inappwebview: ^6.0.0 

# Add the following dependency overrides for iOS & macOS, as needed -->
dependency_overrides:
  flutter_inappwebview_ios:
    git:
      url: https://github.com/andychucs/flutter_inappwebview.git
      ref: master
      path: flutter_inappwebview_ios

  flutter_inappwebview_macos:
    git:
      url: https://github.com/andychucs/flutter_inappwebview.git
      ref: master
      path: flutter_inappwebview_macos
# <--

@amit-iconflux
Copy link

+1

@radvansky-tomas
Copy link

I also cleaned project, even added dependency overrides, pinned versions...and still nothing :(

@pichillilorenzo
Copy link
Owner

I was able to update the dependencies of the https://github.com/pichillilorenzo/flutter_browser_app app and I didn't have any problems on iOS.
Be sure to have flutter_inappwebview: ^6.1.0+1 as your dependency in your pubspec.yaml. file.
Then, try this way:

$ flutter clean
$ flutter pub get
$ cd ios
$ rm Podfile.lock
$ pod install

and run your app on iOS.

@Tobi696
Copy link

Tobi696 commented Sep 24, 2024

still got the issue in 6.1.0+1

@andynewman10
Copy link

andynewman10 commented Sep 24, 2024

@pichillilorenzo it does not work. It's 100% sure.

I triple checked everything, and your flutter_inappwebview package cannot be used on Xcode 15.x. It's that simple (and I'm sorry for it).

The error is invariably:

Could not build the precompiled application for the device.
Swift Compiler Error (Xcode): Method does not override any method from its superclass
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:1431:25

I tried resetting Xcode in all possible and imaginable ways, upgrading to Ventura 13.7 (released yesterday), of course recreating all Pods and everything, all I managed to do was to get the above-mentioned error, with the addition of the following errors, too:

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:1035:20

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:1038:16

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:1047:20

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:1050:16

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:1327:25

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:1912:8

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:2859:22

Swift Compiler Error (Xcode): Ambiguous use of 'evaluateJavaScript(_:completionHandler:)'
/Users/andy/.pub-cache/hosted/pub.dev/flutter_inappwebview_ios-1.1.0/ios/Classes/InAppWebView/InAppWebView.swift:2870:22

The only (not really cool) workaround is to use this solution:

#2274

making sure ref: xcode-15-fix is used, and not ref: master (otherwise it won't work).

Again, I am not mentioning here a problem with Xcode 16, just Xcode 15.x. Your package no longer works with Xcode 15 as it is currently published in pub.dev.

Can I suggest that you look at the above listed 'xcode-15-fix' fix, and apply it to your codebase, in addition to the fix for Xcode 16. Many people still use Xcode 15 and still will for a while.

@andynewman10
Copy link

@pichillilorenzo if I can help (testing on my setup), let me know. The thing is, I am not too familiar with iOS/Swift programming.

My iPhoneOS.platform SDK version is 17.2 (latest version available for Xcode on Ventura), as shown in

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/version.plist

Maybe you are using a different SDK version?

I wonder if conditional compilation directives couldn't be used here? if @available(iOS 18, *) or if compiler(>=5.xxx)? This way, the code would work with both Xcode 15 and 16 (I mean... SDK 17.2 and 18?).

@pichillilorenzo
Copy link
Owner

@andynewman10 currently the new version works only with XCode >= 16.0, so it won't work on XCode 15.x
I thought you were having the problem with XCode 16, but if you are using XCode 15, then it won't work.
The Apple/Webkit team literally changed the WKWebView.evaluateJavaScript signature, which this plugin overrides.
If possible, you should update to XCode 16.0.

Currently, I haven't found a compilation directive to check XCode versions or if there is something that could be used to support both XCode 15 and 16.

@pichillilorenzo
Copy link
Owner

Maybe __IPHONE_OS_VERSION_MAX_ALLOWED or __IPHONE_OS_VERSION_MIN_REQUIRED  could be used?
Check: https://stackoverflow.com/a/8050536/4637638

@pichillilorenzo
Copy link
Owner

Moved to: #2288

@pichillilorenzo
Copy link
Owner

Released new flutter_inappwebview_ios and flutter_inappwebview_macos version 1.1.0+1 with the fix! I was able to use #if compiler(>=6.0) for Swift.
XCode 16 uses the Swift 6.0 compiler (more info here: https://xcodereleases.com/), so in the "else" statement we can use the "old" version of the "evaluateJavaScript" method.

You can run flutter pub upgrade to update the dependencies.

@akshayAtDWI
Copy link

I updated Mac OS to beta versions and it won't let me downgrade to Xcode 15.4 now. I am stuck with Xcode 16, Any help would be appreciated.

Stucked in the same situatuin, if you find any solution, please let me know.

@pichillilorenzo
Copy link
Owner

pichillilorenzo commented Sep 29, 2024

@akshayAtDWI update the flutter_inappwebview plugin to the latest version.

@ybbond
Copy link

ybbond commented Oct 7, 2024

EDIT:

I've found the solution here #2201 (comment)

thanks!


pardon to resurrect the issue @pichillilorenzo, but is there any other alternative to upgrading flutter_inappwebview (such as manually edit Podfile dependency code) ?

The thing is to update the pub package require us to upgrade Flutter, which we cannot do in the meantime.

Thanks before

@bitspad
Copy link

bitspad commented Oct 13, 2024

I clicked on the error, and I deleted one like this, then it worked!

 public override func evaluateJavaScript(_ javaScriptString: String, completionHandler: ((Any?, Error?) -> Void)? = nil) {
        if let applePayAPIEnabled = options?.applePayAPIEnabled, applePayAPIEnabled {
            if let completionHandler = completionHandler {
                completionHandler(nil, nil)
            }
            return
        }
        super.evaluateJavaScript(javaScriptString, completionHandler: completionHandler)
    } 

This is the best solution, it works for me.

@Aladdin-Shaker
Copy link

Aladdin-Shaker commented Oct 25, 2024

Has anyone tried to solve it, please?

Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1
Xcode 16

@pichillilorenzo
Copy link
Owner

@Aladdin-Shaker the latest plugin works with Flutter 3.24+. If you can update Flutter, then you can update also the plugin.

@Aladdin-Shaker
Copy link

Aladdin-Shaker commented Oct 25, 2024

@Aladdin-Shaker the latest plugin works with Flutter 3.24+. If you can update Flutter, then you can update also the plugin.

Thanks, do you mean flutter_inappwebview ?

@pichillilorenzo
Copy link
Owner

@Aladdin-Shaker yes 👍

@Aladdin-Shaker
Copy link

@Aladdin-Shaker yes 👍

Thanks :)

@chalananupun
Copy link

I clicked on the error, and I deleted one like this, then it worked!

 public override func evaluateJavaScript(_ javaScriptString: String, completionHandler: ((Any?, Error?) -> Void)? = nil) {
        if let applePayAPIEnabled = options?.applePayAPIEnabled, applePayAPIEnabled {
            if let completionHandler = completionHandler {
                completionHandler(nil, nil)
            }
            return
        }
        super.evaluateJavaScript(javaScriptString, completionHandler: completionHandler)
    } 

This is worked me. Thanks ❤️

@richanshah
Copy link

is there new plugin update with this fix?

@Aladdin-Shaker
Copy link

is there new plugin update with this fix?

No, I have upgraded the Flutter version with the packages

@pichillilorenzo
Copy link
Owner

Yes, you need to update the plugin @qwertylolman

the latest plugin works with Flutter 3.24+. If you can update Flutter, then you can update also the plugin.

@richanshah
Copy link

i have upgraded dependencies and flutter to latest and it is running but not working properly.

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 and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests