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

Swift 6 Support #33

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Swift 6 Support #33

wants to merge 9 commits into from

Conversation

Firehed
Copy link
Contributor

@Firehed Firehed commented Jul 28, 2024

Adopts Swift 6 and its data race safety features. This should be a non-breaking change in terms of code (it didn't require changes to the sample app used to test the SDK), but does seem to require being on the latest XCode beta which could trigger some workflow breakage. I'm not sure the best way to handle that in terms of versioning, but in any case I'm temporarily blocked by the supported CI actions.

To make this work, the following changes were adopted:

  • @MainActor added to the SDK
  • Sendable added to a couple data structures
  • ASPresentationAnchor.default extension reworked as a computed property instead of a fileprivate let
  • The ASAuthorizationControllerDelegate methods are marked nonisolated (required for protocol compliance), and some of their internals are wrapped in Task { @MainActor in ... } to get back to the right actor.

I tried a couple other approaches that felt like they'd be less likely to hog resources on the main thread (generally, trying to make SnapAuth conform to Sendable or turn into an Actor) that clearly weren't going anywhere without pretty substantial refactoring. I won't pretend to be a Swift expert; if someone who is chimes in with a better way, this can be revisited.

Posting as-is for review, but the CI tooling will need some updates before this will build and can be landed. I expect this will solidify closer to the fall OS releases.

Fixes #26

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.

Add Swift 6 compatibility and data race safety
1 participant