From 08cce91e779bafee26828f4232a5e0b42718056f Mon Sep 17 00:00:00 2001 From: gsdali <51393997+gsdali@users.noreply.github.com> Date: Thu, 2 Jul 2026 06:46:40 +0900 Subject: [PATCH] fix(deps): guard sibling-detection against .build/checkouts false-positive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The occtDep helper used a local `.package(path: "../")` whenever `..//Package.swift` existed. SwiftPM lays every transitive checkout out flat under one `.build/checkouts/`, so when this manifest is itself resolved as a dependency, `../` spuriously exists and flips the dep to a path — which conflicts with the same package resolved by URL elsewhere in the graph, so SwiftPM emits a "Conflicting identity" warning (slated to become a hard error). Guard the sibling branch with `!manifestDir.contains("/.build/")` so only a real local dev clone takes the path dep. Mirrors SecondMouseAU/OCCTSwiftScripts#70. Refs SecondMouseAU/ecosystem#14. Co-Authored-By: Claude Opus 4.8 (1M context) --- Package.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index a9e4b3c..aa83ede 100644 --- a/Package.swift +++ b/Package.swift @@ -9,7 +9,12 @@ import Foundation // so it's independent of build CWD. func occtDep(_ name: String, from version: String) -> Package.Dependency { let manifestDir = URL(fileURLWithPath: #filePath).deletingLastPathComponent().path - if FileManager.default.fileExists(atPath: manifestDir + "/../\(name)/Package.swift") { + // Only trust a sibling checkout for a REAL local dev clone — never when this manifest is itself a + // transitively-resolved checkout under a consumer's `.build/checkouts/` (SwiftPM lays every dep out + // flat there, so `../\(name)` spuriously exists and flips this to a path dep → a SwiftPM identity + // conflict with the URL-based dep. See SecondMouseAU/ecosystem#14. + if !manifestDir.contains("/.build/"), + FileManager.default.fileExists(atPath: manifestDir + "/../\(name)/Package.swift") { return .package(path: "../\(name)") } return .package(url: "https://github.com/SecondMouseAU/\(name).git", from: Version(version)!)