Skip to content

Fix WKNavigationDelegate policy signatures#320

Open
kieran-osgood-shopify wants to merge 1 commit into
mainfrom
kieran-osgood/checkout-webview/fix-navigation-delegate-signatures
Open

Fix WKNavigationDelegate policy signatures#320
kieran-osgood-shopify wants to merge 1 commit into
mainfrom
kieran-osgood/checkout-webview/fix-navigation-delegate-signatures

Conversation

@kieran-osgood-shopify

@kieran-osgood-shopify kieran-osgood-shopify commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What changes are you making?

Fix the Swift WKNavigationDelegate policy callback signatures on CheckoutWebView so they match the current WebKit protocol requirements.

The existing methods were missing @MainActor @Sendable on the decisionHandler closure, so Swift warned that they only "nearly" matched the optional WKNavigationDelegate requirements. That means WebKit may not dispatch navigation action/response policy callbacks to the SDK at runtime, even though direct unit tests that call the methods still pass.

This also enables warnings-as-errors for the shipped Swift package targets only:

  • ShopifyCheckoutProtocol
  • ShopifyCheckoutKit
  • ShopifyAcceleratedCheckouts

That keeps this guardrail focused on our library code instead of test-only dependencies like ViewInspector. To use SwiftPM's first-class .treatAllWarnings(as: .error) setting, the manifest tools version is bumped from 6.0 to 6.2.

Why?

The checkout HTTP error handling path depends on webView(_:decidePolicyFor:decisionHandler:) for navigation responses calling handleResponse(_:). If WebKit does not see the selector as implemented, 4xx/5xx checkout responses can render or leave the sheet blank instead of flowing through the SDK's intended error handling.

Existing tests did not fail because they call handleResponse(_:) or the Swift methods directly, bypassing Objective-C optional-protocol selector dispatch. This PR adds a regression test that checks the CheckoutWebView instance responds to the WebKit policy selectors.

Enabling warnings-as-errors on the package library targets would have caught the original warning at build time while avoiding noise from test targets and third-party test dependencies.

How to test

  • shadowenv exec -- env CURRENT_SIMULATOR_UUID=48B8B315-0429-4EB2-A482-F5223CBD96D7 platforms/swift/Scripts/xcode_run test ShopifyCheckoutKit-Package CheckoutWebViewTests
  • shadowenv exec -- env CURRENT_SIMULATOR_UUID=48B8B315-0429-4EB2-A482-F5223CBD96D7 /opt/dev/bin/dev swift build packages
  • shadowenv exec -- /opt/dev/bin/dev swift lint
  • shadowenv exec -- env CURRENT_SIMULATOR_UUID=48B8B315-0429-4EB2-A482-F5223CBD96D7 /opt/dev/bin/dev swift test

Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (platforms/swift/README.md and/or platforms/android/README.md)

Releasing a new Swift version?
  • I have bumped the version in ShopifyCheckoutKit.podspec
  • I have bumped the version in platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift
  • I have updated platforms/swift/CHANGELOG.md
  • I have updated the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Android version?
  • I have bumped the versionName in platforms/android/lib/build.gradle
  • I have updated platforms/android/CHANGELOG.md
  • I have updated the Gradle/Maven version snippets in platforms/android/README.md

Tip

See the Contributing documentation for the full release process per platform.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as ready for review June 23, 2026 11:12
@kieran-osgood-shopify kieran-osgood-shopify requested a review from a team as a code owner June 23, 2026 11:12
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 92%
91.66% (319/348) 87.86% (181/206) 100% (82/82)

Assisted-By: devx/058cd5b9-f1cc-431b-b520-15657ace50f1
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/checkout-webview/fix-navigation-delegate-signatures branch from b060e6d to 058ec1e Compare June 23, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants