Can't build a canvas with swift 5.2 toolchain

I created a new SwiftUI project via:

Xcode Version 11.3
Toolchain: Swift 5.2 Snapshot 2020-01-11

When i'm trying to build a new "Hello world" project in the canvas and I get error below:

Compiling failed: module compiled with Swift 5.1.3 cannot be imported by the Swift 5.2 compiler

Video from my twitter.

Clean and rebuild your project. Unless you’re importing precompiled Swift frameworks, in which case they need to be recompiled too, long bless they’ve been built in library evolution mode.

Clean and rebuild doesn't work.
New "Hello World" project also have this issue.

Hmm, perhaps the canvas compiler doesn’t use toolchains. I’m surprised Apple painted themselves into this corner again.

I’ve also noticed issues with other modules in the 5.2 toolchain.

1 Like

Sounds like the SwiftUI frameworks are not module stable. Since they are still private frameworks, and are meant to work with a specific version of Xcode and swiftc, this makes a lot of sense.

Is the error message in your png resulting from building your "Hello, world!" app only? No other swift frameworks or modules are being used other than system frameworks?

Just a SwiftUI "Hello, World" app:

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("Hello, World!")
    }
}

Not even that, they aren’t built with the toolchain compiler like the rest of the project.

Probably can't use the toolchain compiler because the underlying frameworks and other parts of Xcode that the compiled code relies on to actually display the canvas are probably not module stable, for the reasons I mentioned previously.

All of this is purely speculation until Apple chooses to comment on this.

I wonder what would happen if the OP actually built and ran the application using the 5.2 toolchain?

You’re probably right on that count. Personally, I haven’t yet been able to get a successful build out of 5.2 due to issues building some Combine APIs.

Yeah, Combine is still an Apple-private framework. Probably not module stable, for same reasons.

It’s not private, it ships with the OS like everything else, and it is built for evolution. However, it seems 5.2 cant see all of the symbols it produces, so I get errors on some APIs.

That's good to know when or if I start to use Combine.

I guess that’s because some features (like function builders) were still WIP when it was announced.

1 Like