[Bug] Incorrect dependency build order in SPM

Recently I began porting our frameworks to SPM. We use trunk-based development and have all of our code in a mono-repository, so all of the packages are local.

I've stumbled upon a peculiar problem while building one of the packages. SPM seems to process one of the dependencies of my target after trying to build the target itself. So every build after the first one is successful, but the first one always fails.

Here is my package manifest
// swift-tools-version:5.3
import PackageDescription

let package = Package(
    name: "KLStatistics",
    platforms: [
         .macOS(.v10_15), .iOS(.v10)
    products: [
        .library(name: "KLStatistics_Core", targets: ["KLStatistics_Core"]),
        .library(name: "KLStatistics_Firebase", targets: ["KLStatistics_Firebase"])
    dependencies: [
        .package(name: "KLFoundation", path: "../KLFoundation"),
        .package(name: "KLFirebase", path: "../KLFirebase")
    targets: [
        .target(name: "KLStatistics_Core",
                dependencies: ["KLFoundation"],
                path: "KLStatistics_Core/Source"),
        .target(name: "KLStatistics_Firebase",
                dependencies: ["KLFoundation", "KLFirebase", "KLStatistics_Core"],
                path: "KLStatistics_Firebase/Source",
                publicHeadersPath: ".")

And here is the build log

It should be noted that both KLFoundation and KLFirebase dependencies are binary frameworks, wrapped into Swift packages

Hi, @apstygo
Have you been able to work around this issue?
I've encountered it too while trying to build my SPM module which depends upon couple of binary targets. In my case these binary targets are C-libraries and the error states that headers are not found.

Oddly enough, build only fails when I add this module as SPM dependency to Xcode project.
When I build it standalone in Xcode (via opening Package.swift) everything works just fine.

I am using Xcode 12.5

I'm seeing what seems to be the same issue, and I haven't found a solution yet. Xcode 12.5.1. Using SPM, including package A that depends on package B which uses a binaryTarget, and SPM tries to build package A first.

Terms of Service

Privacy Policy

Cookie Policy