-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support Xcode 16.2 onPreferenceChange
SDK change
#48
Conversation
There's also a concurrency warning in |
@Supereg Please do a quick review of the PR, would be great to get this code in soon as the Xcode 16.2 RC was released nearly a week ago (Dec 5), meaning that the public release will probably come in a couple of days. Just noticed: I didn't take a look into why the snapshot tests fail yet, will probably be better if you take a quick glance into that, would be way quicker! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #48 +/- ##
==========================================
- Coverage 74.97% 74.91% -0.06%
==========================================
Files 52 52
Lines 1574 1586 +12
==========================================
+ Hits 1180 1188 +8
- Misses 394 398 +4
Continue to review full report in Codecov by Sentry.
|
@PSchmiedmayer Please merge the PR with bypassing merge requirements. Minor decrease in test coverage as we added a "safety" case in case SwiftUI ever moves the |
Amazing, thank you for the fix @philippzagar! |
Support Xcode 16.2
onPreferenceChange
SDK change♻️ Current situation & Problem
As shown in #47 and StanfordSpezi/SpeziLLM#76, Apple chose to change the signature of the
onPreferenceChange
view modifier in SwiftUI with the latest Xcode 16.2 RC (also the betas) and the iOS 18.2 SDKs.In its current state, this prevents the SpeziViews package from compiling in these environments.
The
onPreferenceChange
view modfier now takes a@Sendable
closure, therefore we cannot capture@MainActor
isolated properties on theView
directly anymore: https://developer.apple.com/documentation/swiftui/view/onpreferencechange(_:perform:)?changes=latest_minorHowever, as the
@Sendable
closure is still run on the MainActor's serial executor (at least in my testing on 18.2 RC SDKs), we can useMainActor.assumeIsolated
to avoid scheduling aMainActor
Task
, which could delay execution and cause unexpected UI behavior.⚙️ Release Notes
onPreferenceChange
SDK change📚 Documentation
Properly documented in-line why this change was necessary
✅ Testing
Tested the changes locally on Xcode 16.2 RC as well as iOS 18.2 betas.
We should lifting the CI builds / testing to these versions as well, as soon as they're out (should only be a couple of days).
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: