Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonnickel/fb14108914-swift6bindingisolatedcrash
https://github.com/simonnickel/fb14108914-swift6bindingisolatedcrash
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/simonnickel/fb14108914-swift6bindingisolatedcrash
- Owner: simonnickel
- Created: 2024-06-28T09:09:02.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-28T12:14:14.000Z (7 months ago)
- Last Synced: 2024-12-16T16:06:20.365Z (about 1 month ago)
- Language: Swift
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FB14108914 - Swift 6: Binding with isolated closures failes to compile / crashes
## Scenario
A SwiftUI app has a class that provides a custom Binding where the closures capture self to store the value.
## Issue
To be compliant with Swift 6 strict concurrency checking, the class and the closures are isolated to @MainActor.
When compiling with Swift 5.10 and strict concurrency checking = complete, there are no warnings and the binding is working fine.
When compiling with Swift 6, the code fails to compile without proper error message (see file: Build Swift6BindingIsolatedCrash_2024-06-28T10-51-08.txt).~~In the actual project I encountered this issue, it was able to build, but the app crashed on initialisation of the binding. In this case, the binding is defined in a package with swiftLanguageVersions: [.version("6")] set and the consuming project set to compile with Swift 6.~~
Update: When the class is defined using Generics, the code compiles but crashes when the Binding is created.
## Example codeThe example shows a Toggle, which uses a binding setup as described above.
There are 2 implementations of the BindingProvider:
1. Without Generics: When compiled with Swift 5, it works fine. When compiled with Swift 6 it fails.
2. With Generics: Compiles with Swift 5 and 6, but crashes with Swift 6.## Tested on
- Xcode Version 16.0 beta (16A5171c)