Skip to content

Mark CheckoutKit UI as main actor isolated#84

Open
kieran-osgood-shopify wants to merge 1 commit into
mainfrom
kieran-osgood/swift6/mainactor-checkoutkit-ui
Open

Mark CheckoutKit UI as main actor isolated#84
kieran-osgood-shopify wants to merge 1 commit into
mainfrom
kieran-osgood/swift6/mainactor-checkoutkit-ui

Conversation

@kieran-osgood-shopify

@kieran-osgood-shopify kieran-osgood-shopify commented May 13, 2026

Copy link
Copy Markdown
Contributor

What changes are you making?

This is step 1 towards Swift 6 adoption.
I've marked the CheckoutKit UIKit/WebKit surfaces as @MainActor so Swift 6 callers and implementations treat checkout UI work as main-actor isolated.
There was a gotcha to work around here in the CheckoutWebView.swift - it relied on a deinit to close the bridge.
The gotcha is that in Swift 6.0 class deinit is not isolated to the containing actor (e.g. I've marked @MainActor on class CheckoutWebView, but the deinit still runs nonisolated)

There is a "nice" fix for this in Swift 6.2 but I don't want to bring the minimum compiler target up to 6.2 just yet, but it will allow us to change the declaration to be isolated deinit which solves the issue for us

As a workaround for now and to avoid MainActor.assumeIsolated (runtime failures), bridge registration is wrapped in a small helper class, that is created on the MainActor while CheckoutWebView is being configured.

It captures a reference to the WKUserContentController at that safe call site, detaches synchronously when detachBridge() is called on the main actor, and schedules fallback teardown back onto MainActor from its own deinit.

How to test

shadowenv exec --dir /Users/ko/src/github.com/Shopify/checkout-kit -- /opt/dev/bin/dev swift test CheckoutWebViewTests
shadowenv exec --dir /Users/ko/src/github.com/Shopify/checkout-kit -- /opt/dev/bin/dev swift format

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 platforms/swift/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.

kieran-osgood-shopify commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions

github-actions Bot commented Jun 10, 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)

@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/mainactor-checkoutkit-ui branch 3 times, most recently from e5d6371 to 1d19f91 Compare June 11, 2026 10:23
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/swift6/mainactor-checkoutkit-ui branch from 1d19f91 to 87179cb Compare June 11, 2026 10:32
@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as ready for review June 11, 2026 11:10
@kieran-osgood-shopify kieran-osgood-shopify requested a review from a team as a code owner June 11, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant