Failed to build the scheme on Preview canvas

I am developing a multi-platform app.

Added a package that imports UIKit to the project under development.

Changed "Allow any platform" to "iOS" in the framework settings of the project.

In the source using the library, "#if os(iOS)" is applied to iOS only.

The project compiles without errors on iOS and macOS and runs normally.

It works normally in the preview canvas of iOS.

The preview canvas on macOS throws a UIKit error in the library.

With just a few lines of code you can check this error.

[Package]

import UIKit <--------

public struct MyLibrary {
  public private(set) var text = "Hello, World!"

  public init() {
  }
}

[Project]

import SwiftUI
#if os(iOS)         <---------------
import MyLibrary
#endif

struct ContentView: View {
  var body: some View {
    VStack {
      Image(systemName: "globe")
        .imageScale(.large)
        .foregroundColor(.accentColor)
      Text("Hello, world!")
    }
  }
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}
Failed to build the scheme on Preview canvas
 
 
Q