Xcode previews stop working in packages after adding a dependency

I created a brand new swift package, added a simple SwiftUI view, and opened the canvas to view the preview. This all worked great. Then I added a dependency to my package. After adding the dependency previews stop working. Here is my final Package.swift

Code Block
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyTestPackage",
platforms: [
.iOS(.v14),
.macOS(.v10_15)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "MyTestPackage",
targets: ["MyTestPackage"]),
],
dependencies: [
.package(url: "https://github.com/pointfreeco/swift-composable-architecture", from: "0.6.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "MyTestPackage",
dependencies: [
.product(name: "ComposableArchitecture", package: "swift-composable-architecture")
]),
.testTarget(
name: "MyTestPackageTests",
dependencies: ["MyTestPackage"]),
]
)


The app compiles successfully via ⌘B, but the preview fails with the following error.

Code Block
build aborted due to an internal error: planningFailed("multiple configured targets of \'ComposableArchitecture\' are being created for iOS Simulator")
----------------------------------------
SchemeBuildError: Failed to build the scheme "MyTestPackage"
unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'ComposableArchitecture\' are being created for iOS Simulator")
Build system information:
error: unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'ComposableArchitecture\' are being created for iOS Simulator")

We are facing the exact same issue - no solution so far
Daniel
Similar issue with the same error message for me.
From a first library named "MyViews", I need to access a resource that is in a second library named "MyResources".
If I run my app, it is working but the Xcode Preview produces this error:
Code Block
build aborted due to an internal error: planningFailed("multiple configured targets of \'MyResources\' are being created for iOS Simulator")
----------------------------------------
SchemeBuildError: Failed to build the scheme "ResourcesInAnotherModule"
unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'MyResources\' are being created for iOS Simulator")
Build system information:
error: unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'MyResources\' are being created for iOS Simulator")


My package is:
Code Block
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
    name: "MyPackage",
    platforms: [SupportedPlatform.iOS(.v14)],
    products: [
        .library(
            name: "MyViews",
            targets: ["MyViews"]),
        .library(
            name: "MyResources",
            targets: ["MyResources"]),
    ],
    targets: [
        .target(
            name: "MyViews",
            dependencies: ["MyResources"]),
        .target(
            name: "MyResources",
            dependencies: []),
    ]
)


I have open a bug in Apple's Feedback Assistant for that issue with my project sample, number FB8930185.
I saw that someone on SO said they got it to work by adding type: .dynamic, to the products parameter after name in .library like so:

Code Block swift
products: [
.library(
name: "MyTestPackage",
type: .dynamic,
targets: ["MyTestPackage"]),
],


Xcode previews stop working in packages after adding a dependency
 
 
Q