Search code examples
iosswiftxcodeswift-package-manager

Xcode SPM - product [product] required by package [package] target [target] not found


I use SPM in my project and want to integrate Texture. My project is divided into different modules using SPM. I want to use Texture only in one.

The problem is that Texture does not support SPM. I forked from this PR that supports SPM. I've successfully integrated Texture in my project, but can't use it.

My Package.swift:

let targets: [Target] = [
    .target(name: "MyTarget", dependencies: ["Texture"]),
]

let package = Package(
    name: "MyPackage",
    platforms: [.iOS(.v14), .macOS(.v10_15)],
    products: targets.filter { !$0.isTest }.map { .library(name: $0.name, targets: [$0.name]) },
    dependencies: [
        .package(name: "Texture", url: "https://github.com/bejeri4/Texture.git", .branch("spm")),
    ],
    targets: targets)
)

When I add Texture as a dependency to my local package, I get the following error:

product 'Texture' required by package 'MyPackage' target 'MyTarget' not found.


Solution

  • I think in the dependencies of your target you need to specify a product of the package Texture, not the package name itself. The products are AsyncDisplayKit and AsyncDisplayKitIGListKit:

    So you should modify the targets to use one of the products like this:

    let asyncDisplayKit = Target.product(name: "AsyncDisplayKit", package: "Texture")
    
    let targets: [Target] = [
        .target(name: "MyTarget", dependencies: [asyncDisplayKit]),
    ]