Skip to content

Fix Swift 6.4 concurrency warnings - #823

Open
stackotter wants to merge 1 commit into
mainfrom
stackotter/fix_conc_warnings
Open

stackotter wants to merge 1 commit into
mainfrom
stackotter/fix_conc_warnings

Conversation

@stackotter

@stackotter stackotter commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

This PR fixes some Swift 6.4 concurrency warnings. The changes to DefaultBackend cause some backend-specific details to leak, because re-exporting the backend classes also causes extensions from their modules to get re-exported. E.g. importing DefaultBackend now gives you access to the inspectWindow modifier. I don't think there's any other way to make this work, so this approach will have to do.

The other main issue was that backends that have been split into a file per backend no longer conformed to Sendable in the file declaring their main backend class. This was an easy fix; I just added explicit Sendable conformances to the class declarations.

Approaches to fixing the DefaultBackend concurrency issues were explored using AI while I did something else.


For completeness, here's the main concurrency warning that prompted these changes:

/Users/stackotter/Desktop/Projects/SwiftCrossUI/SwiftCrossUI/Sources/AppKitBackend/Features/Widgets.swift:4:1: warning: conformance to 'Sendable' must occur in the same source file as class 'AppKitBackend'; use '@unchecked Sendable' for retroactive conformance; this will be an error in a future Swift language mode
 2 | @_spi(Backends) import SwiftCrossUI
 3 |
 4 | extension AppKitBackend: BackendFeatures.Widgets {
   | `- warning: conformance to 'Sendable' must occur in the same source file as class 'AppKitBackend'; use '@unchecked Sendable' for retroactive conformance; this will be an error in a future Swift language mode
 5 |     public typealias Widget = NSView
 6 |

You get that warning if you import DefaultBackend in your main App file as a user of SwiftCrossUI. And only if you were using Swift 6.4

@bbrk24

bbrk24 commented Nov 28, 2026

Copy link
Copy Markdown
Member

I haven't tested anything yet and won't be able to for several hours, but the code looks reasonable enough to me. (Saying this since I was requested as a code owner.)

This branch has not been deployed

No deployments
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