Error: Missing package product only in XCode

I am encountering a strange "Missing package product '(package name)' error that manifests only in XCode, but not in the command-line.

I tried to isolate the problem into two new packages and it behaves the same with the new packages as it does with the original - I can replicate it.

Having the following directory layout :

SOME_ROOT/
    MyTool/
        Package.swift
        ...
    ProtoLib/
        Package.swift
        Sources/
             MyCore/
             MyFlows/
        ...

The MyTool Package.swift looks like:

// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "MyTool",
    platforms: [.macOS("13"), .custom("linux", versionString: "1")],
    products: [
        .library(
            name: "MyTool",
            targets: ["MyTool"]),
    ],
    dependencies: [
        .package(path: "../ProtoLib"),
    ],

    targets: [
        .target(
            name: "MyTool",
            dependencies: [
                .product(name: "MyCore", package: "ProtoLib"),
                .product(name: "MyFlows", package: "ProtoLib"),
            ]
        ),
        .testTarget(
            name: "MyToolTests",
            dependencies: ["MyTool"]),
    ]
)

The ProtoLib package:

// swift-tools-version: 5.9

import PackageDescription

let package = Package(
    name: "ProtoLib",
    platforms: [.macOS("13"), .custom("linux", versionString: "1")],
    products: [
        
        .library(
            name: "MyCore",
            targets: ["MyCore"]),
        .library(
            name: "MyFlows",
            targets: ["MyFlows"])
    ],
    targets: [
        .target(
            name: "MyCore"),
        .target(
            name: "MyFlows",
            dependencies: ["MyCore"])
    ]
)

The ProtoLib has two libraries that are incubated for the time being under one package (multiple reasons, mostly convenience).

When I build the project using command-line swift everything is fine, the project builds without any issues.

When I try to build the MyTool project using XCode I am getting two errors:

  • .../MyTool/Package.swift Missing package product 'MyCore'
  • .../MyTool/Package.swift Missing package product 'MyFlows'

What I am doing wrong? How to make the project build in XCode?

Versions:

  • XCode: Version 15.0 (15A240d)
  • swift version (command-line): swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1) Target: arm64-apple-macosx13.0
Answered by Stiivi in 768048022

This seems to be fixed in XCode Version 15.1 beta (15C5028h).

Accepted Answer

This seems to be fixed in XCode Version 15.1 beta (15C5028h).

Error: Missing package product only in XCode
 
 
Q