TIL: CATiledLayer and Swift Concurrency do not mix.
I did the trick where UIView.layerClass returns CATiledLayer.self so my (large) UIView is performant. But that means parts of UIView now get called on background threads, and Swift._checkExpectedExecutor() gets all assert-y.
Not sure if there's a way around this.
22.3.2025 21:57TIL: CATiledLayer and Swift Concurrency do not mix.I did the trick where UIView.layerClass returns CATiledLayer.self so my (large) UIView is...*sigh*
This is just yet another sign I'm getting old and curmudgeonly. I _strongly_ prefer predictable over "magical”.
25.1.2025 16:20*sigh*This is just yet another sign I'm getting old and curmudgeonly. I _strongly_ prefer predictable over "magical”.Confession: web browser tab management confuses the heck outta me. When I open a new tab or close the tab I'm on, I have literally no idea where the browser is going to take me. It might as well be RNG.
The thing is, the behavior is sophisticated enough that there must have been tons of UX research into how build this. All thwarted because I'm too old and/or stupid to understand their algorithm. Sorry I let you down.
25.1.2025 16:18Confession: web browser tab management confuses the heck outta me. When I open a new tab or close the tab I'm on, I have literally no...Can I make KeyPaths work with async properties at all?
Compiler seems to imply "no" but I can't find any discussions about this when googling.
17.1.2025 16:59Can I make KeyPaths work with async properties at all? Compiler seems to imply "no" but I can't find any discussions about...On the other hand, if you do something boneheaded (which is apparently a preferred pastime of mine) and ask a `Picker` to select a value that's not _in_ the `Picker`, it'll emit a helpful console message telling you that, along with the missing tag. Helpful!
12.1.2025 15:32On the other hand, if you do something boneheaded (which is apparently a preferred pastime of mine) and ask a `Picker` to select a value...SwiftUI’s `Picker` has multiple selection support via its `init(_:sources:selection:)` constructor, which is incredibly useful. Unfortunately, I've discovered if `sources` ever goes empty it just crashes with nary a log message or indicator as to why.
12.1.2025 15:29SwiftUI’s `Picker` has multiple selection support via its `init(_:sources:selection:)` constructor, which is incredibly useful....I just wrote my first test using the new Swift Testing framework. Pleased to report it did _not_ crash the compiler.
(Although the day is still young)
21.9.2024 16:00I just wrote my first test using the new Swift Testing framework. Pleased to report it did _not_ crash the compiler. (Although the day is...lol, I shouldn't have said anything. As soon as I try to instantiate said type that uses parameter pack iteration, compiler crash.
21.9.2024 14:44lol, I shouldn't have said anything. As soon as I try to instantiate said type that uses parameter pack iteration, compiler crash.Parameter pack iteration in Swift 6 is all I hoped it could be.
https://www.swift.org/blog/pack-iteration/
21.9.2024 14:38Parameter pack iteration in Swift 6 is all I hoped it could be. https://www.swift.org/blog/pack-iteration/...and with that, this small side project (a few thousand lines of Swift) is fully Swift 6. Took about a day's worth of work.
The big things were macros (crasher + updating to new SwiftSyntax) and concurrency. Strict concurrency on 5.10 had gotten me pretty far, but not all the way.
20.9.2024 23:39...and with that, this small side project (a few thousand lines of Swift) is fully Swift 6. Took about a day's worth of work.The big...…ok, a bit of an exaggeration. More like 50%.
20.9.2024 23:29…ok, a bit of an exaggeration. More like 50%.90% of my assertMacroExpansion unit tests fail because of whitespace changes caused by updating SwiftSyntax to 6.
Parameter packs still appear to be non-Sendable even if contained types are. See https://github.com/swiftlang/swift/issues/74484
However, the work around in this Stack Overflow appears to work: https://stackoverflow.com/questions/78618908/swift-parameter-packs-and-sendable
Basically, expand out into tuple, send that across concurrency boundaries since tuples are Sendable, then repeat each the tuple.
20.9.2024 23:05Parameter packs still appear to be non-Sendable even if contained types are. See https://github.com/swiftlang/swift/issues/74484However, the...`DispatchData` is not Sendable
Answer: add in `Sendable` conformance to the key path type:
func myFunc(keyPath: WritableKeyPath<Value, ToValue> & Sendable)
20.9.2024 19:51Answer: add in `Sendable` conformance to the key path type:func myFunc(keyPath: WritableKeyPath<Value, ToValue> & Sendable)In Swift 6, what's the correct way to deal with KeyPaths not being Sendable? I can find lots of comments online (and hacks), but it's not clear what the "blessed" path is.
20.9.2024 18:45In Swift 6, what's the correct way to deal with KeyPaths not being Sendable? I can find lots of comments online (and hacks), but...Wait… in Swift 6 can I call an actor's instance method from the init without an `await`???
…
I guess that's a yes. It compiles and does not crash at runtime. Nice!
20.9.2024 18:30Wait… in Swift 6 can I call an actor's instance method from the init without an `await`???…I guess that's a yes. It compiles and...My fix was to have my conformance macro explicitly list both parent and child protocols
20.9.2024 18:03My fix was to have my conformance macro explicitly list both parent and child protocolsI finally figured the crash out, but I’m bewildered. I have protocol SubProtocol which subtypes ParentProtocol. I have a macro which conforms TypeA to SubProtocol (and thus ParentProtocol).
If I write a generic method over a type implementing SubProtocol and pass in TypeA Swift gives confusing errors, but eventually tells me TypeA doesn't declare conformance to ParentProtocol (?!??!)
If a _macro_ writes the said generic method from the previous paragraph, the whole Swift compiler crashes.
20.9.2024 17:57I finally figured the crash out, but I’m bewildered. I have protocol SubProtocol which subtypes ParentProtocol. I have a macro which...I was looking forward to upgrading this side project to Swift 6 to see how my strict concurrency work had fared. But no, now I get to go debug the Swift compiler's macro code generation.
20.9.2024 13:15I was looking forward to upgrading this side project to Swift 6 to see how my strict concurrency work had fared. But no, now I get to go...