Background
I'm looking for ways to improve build times of packages that depend on moreSwift/swift-winui (i.e. apps that use SwiftCrossUI on Windows). Clean debug builds currently take around 10 minutes and clean release builds currently take around 20 minutes. And that's when I'm building it in a VM on my desktop that has 12 cores and more than enough RAM, which is close to the best case scenario.
I've looked into quite a few different ways to improve build times of the swift-winui family of packages, but all approaches that I've tried have made only marginal improvements, if any at all. In particular, swift-uwp has around 170k lines of generated Swift code, which kind of limits how fast these builds can become without pretty targeted profiling of the Swift compiler.
That's what has led to me looking into distributing pre-built Swift libraries on Windows.
Distributing pre-built Swift libraries on Windows
SE-0482: Binary Static Library Dependencies introduced support for shipping and consuming binary static libraries using SwiftPM on non-Apple platforms, which is almost exactly what I need! Unfortunately, support for Swift static libraries was doomed to the future directions. First, I have a couple of questions;
- Has anyone already put work into supporting that future direction? I'd like to avoid doubling up work if possible
- If not, does anyone familiar with those parts of SwiftPM have a vague idea of how complex the implementation might be? My assumption is that much of the complexity will come from updating the auditing tool?
If I did pursue this approach, I'd probably have to set up a separate swift-winui-prebuilts package that contains prebuilt versions of the library products present in the latest swift-winui releases, which isn't ideal because it'd require some wiring within SwiftCrossUI's package manifest to allow people to opt in and out of the WinUI prebuilts. It'd also require developers to take care when explicitly depending on swift-winui alongside swift-cross-ui in their projects.
Alternative approach 1 (band-aid)
An alternative approach that I've been playing around with is extending SwiftPM's Swift Syntax prebuilts system to support WinUI prebuilts. For now, that'd be in a custom fork of SwiftPM that people can use if they want to speed up their SwiftCrossUI app builds on Windows. That's obviously not ideal, because it requires keeping a SwiftPM fork up to date and maintaining builds for people to use, but once developers have the fork installed, it would provide a more convenient experience, because they could opt in and out of prebuilts from the command line, no matter how they depend on WinUI.
Alternative approach 2 (long term)
The better version of this approach long term (imo) would be to design and implement a 'prebuilts' feature that all packages can adapt across all platforms supported by Swift, but that's likely more work than I have time for at the moment (the evolution process can be quite arduous).
Out of the potential designs I have in mind, I think that the most likely ideas to be accepted would either be some sort of extension of the Registry protocol to allow clients to request prebuilts in place of source code when available, or a new protocol akin to the Registry protocol but specifically for requesting prebuilts. I prefer the latter because it leaves the door open to supporting prebuilts for packages published as GitHub repos. Either way, developers would opt-in per machine/workspace using registry/prebuilt configuration files, eliminating some of the security arguments that I could imagine coming up (because if any prebuilts are to end up in a build, the developer must explicitly opt in).
This approach would also allow developers to use prebuilts for packages that don't officially vend any, and it'd allow different developers to use different prebuilts for the same packages; both of which independent developers and companies would appreciate alike.
@dschaefer2, is opening up prebuilts to third party packages on the table?