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

[webview_flutter_wkwebview] Updates the internal wrapper to use @ProxyApi from pigeon #8311

Open
wants to merge 233 commits into
base: main
Choose a base branch
from

Conversation

bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Dec 16, 2024

Also fixes flutter/flutter#152352

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot removed the p: interactive_media_ads Plugin for IMA SDK label Dec 20, 2024
@bparrishMines bparrishMines marked this pull request as ready for review January 8, 2025 19:52
@bparrishMines bparrishMines changed the title Webview darwin proxy [webview_flutter_wkwebview] Updates the internal wrapper to use @ProxyApi from pigeon Jan 8, 2025
return instance
}

#if compiler(>=6.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MainActor was required for local development with Xcode 16, but our CI doesn't recognize the method because it uses XCode 15. Related to: flutter/flutter#148870

/// Creates an error when a method is called on an unsupported version.
func createUnsupportedVersionError(method: String, versionRequirements: String) -> PigeonError {
return PigeonError(
code: "FWFUnsupportedVersionError",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeps error code consistent with previous implementation.

// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if os(iOS)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: These could be changed to canImport(UIKit) so that other platforms, like tvOS, could be used without changes. But I went with what was used in the Objective-C implementation.

///
/// Since `URLRequest` is a struct, it is pass by value instead of pass by reference. This makes
/// it not possible to modify the properties of a struct with the typical ProxyAPI system.
class URLRequestWrapper {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting FYI for anyone curious and additional context that I can add to the comment if needed:

The Swift URLRequest represents the Objective-C NSURLRequest and MutableNSURLRequest and converts to one or the other depending on the context.

This is different from URL and NSURL, which doesn't have a mutable equivalent. So a URL would always convert to the same NSURL instance when needed.

This distinction might come up when wrapping other structs.

/// change of the plugin. Native code other than this external API does not follow breaking change
/// conventions, so app or plugin clients should not use any other native APIs.
@objc(WebViewFlutterWKWebViewExternalAPI)
public class FWFWebViewFlutterWKWebViewExternalAPI: NSObject {
Copy link
Contributor Author

@bparrishMines bparrishMines Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class was converted to Swift, but the @objc annotations should provide the equivalent method (I wrote the swift test before creating the class).

8FB79B842820A3A400C101D3 /* FWFUIDelegateHostApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FWFUIDelegateHostApiTests.m; path = ../../darwin/Tests/FWFUIDelegateHostApiTests.m; sourceTree = SOURCE_ROOT; };
8FB79B8E2820BAB300C101D3 /* FWFScrollViewHostApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FWFScrollViewHostApiTests.m; path = ../../darwin/Tests/FWFScrollViewHostApiTests.m; sourceTree = SOURCE_ROOT; };
8FB79B902820BAC700C101D3 /* FWFUIViewHostApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FWFUIViewHostApiTests.m; path = ../../darwin/Tests/FWFUIViewHostApiTests.m; sourceTree = SOURCE_ROOT; };
8FB79B962821985200C101D3 /* FWFObjectHostApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = FWFObjectHostApiTests.m; path = ../../darwin/Tests/FWFObjectHostApiTests.m; sourceTree = SOURCE_ROOT; };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stuartmorgan How were you able to get a relative path for the files in darwin/Tests? I had to manually change all the paths in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[webview_flutter] Contributions require special tooling
1 participant