Framework using SwiftUI built with Xcode 16 fails is unusable with Xcode 15

I am unable to use a framework that uses SwiftUI, built with the Xcode 16 release candidate, in Xcode 15.4. Attempting to build an app that uses the pre-built framework results in "Cannot find type 'SwiftUICore' in scope errors in the framework's private swift interface (.private.swiftinterface) file. For example

error: cannot find type 'SwiftUICore' in scope
  @_Concurrency.MainActor @preconcurrency public var body: some SwiftUICore.View {
                                                                ^~~~~~~~~~~

The problem is reproducible by creating a new framework project in Xcode 16, adding SwiftUI code to it, adjusting the deployment target, building the framework, then creating a new app project in Xcode 15.4, adding the framework to it, and attempting to build. In my test framework, I added the following type:

public struct BoldText: View {
    let string: String
    
    public init(_ string: String) {
        self.string = string
    }
    
    public var body: some View {
        Text(string).bold()
    }
}

When I removed that type, a build of the framework with Xcode 16 became useable in Xcode 15.4.

Is this expected or is this a bug?

Is there any update from Apple about it? Seems like a serious issue that breaks framework usage on older xcodes

@esridgeway Thanks for posting the issue!

It sounds like you're encountering a compiler issue likely related to a bug introduced in Xcode 15.4 compiler. Here are a couple of troubleshooting steps you can take:

  1. Rollback to a Previous Xcode 15.4 Version: Try reverting to Xcode 15.3 or earlier and building your framework again. If this works, it strongly suggests that the compiler bug is present in the specific Xcode 15.4 version you have installed.
  2. Remove @preconcurrency and Rebuild: If rolling back isn't an option, remove the @preconcurrency annotation from your code and rebuild your framework.

This issue should be fixed in Xcode 16, as a compiler bug that affects the @preconcurrency annotation was identified and resolved in a later build of Xcode 15.4.

Framework using SwiftUI built with Xcode 16 fails is unusable with Xcode 15
 
 
Q