I hate to complain, but I hit a breaking point tonight. While working on my app in Xcode, I ran into this super-common error (in case the image above is broken or something, it’s the “The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions” error). Again. And the thing you need to know about this error is that it’s a red herring: the problem is almost never that there are too many “sub-expressions” (whatever the hell that means).
This error happens when there’s a genuine syntax error inside the body of the SwiftUI body
. The best and easiest way to solve this error is to remove the most recently-added code. Then, carefully scrutinize that code manually until you determine what you’ve done wrong. Fix that, and this error goes away.
I want to be patient, but I’m at the end of my rope on this stuff. Back when I wrote apps in Objective-C, error messages made sense, and everything was super-fast. Now, we’ve had Swift for 10 years, and SwiftUI for five years. And as far as I can tell, nothing I do on my $5,000 top-of-the-line M4 Pro chipped computer is challenged quite as much as when it’s chewing on Swift code.
Swift is slow. The compiler is farcically slow. SwiftUI previews are a joke; I learned the keyboard shortcut to close the preview window when it periodically shows up in Xcode (it’s Command-Option-Return, in case you have any Preview
blocks), because the previews almost never work.
I’m only half-kidding when I suggest that Swift is an Apple conspiracy to sell MacBooks Pro to developers who will do anything to shave a few seconds off the compile time.
And you know it’s bad, because if you do any other kind of development — such as web development in Go, or script programming — that shit is blindingly fast on this computer. It’s instant. And I could program for days on a single charge. With Xcode, my battery is burned to the ground in 4 hours.
So what’s going on here? I don’t care anymore. I just want it to be better.