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: ".")
]
)
It should be noted that both KLFoundation and KLFirebase dependencies are binary frameworks, wrapped into Swift packages