I've been trying to use the Xcode 14 beta and the -warn-concurrency flag to make some of our library code concurrency-safe, and I've hit just… too many problems to manage.
A smattering of random data points:
- Foundation types that I think should be
Sendable, are not:- URL
- Notification
- ...
- UIKit constants that should not be
@MainActor, are:- UIApplication.willEnterForegroundNotification (it's just a string constant, and NotificationCenter itself is thread-safe)
- UIKit types and methods that I think should not be
@MainActor, are:UIDevice, or at least I should be able to doUIDevice.current.systemVersionfrom any actor
- Dispatch is completely concurrency-unaware — I kinda expected it to be unavailable, but instead it's available but doesn't understand swift concurrency
- It'd at least be nice if
DispatchQueue.main.[a]syncunderstood that its closure can be@MainActor(perhapsmaincould return a subclass ofDispatchQueuewith stronger guarantees?)
- It'd at least be nice if
- SwiftUI Button etc. callbacks aren't marked
@MainActor, even though (AFAIK) they are — certainly it's always been legal to update@Statevars from them — so it's not legal to call UIKit from them (eg. to present a UIViewController in response to a button press)
When can we expect Apple's SDKs to actually be usable with concurrency checking?