Xcode ↔ Swift Package Manager: Conflict Resolution for Shared Dependencies
0 reputation · 14 Jan 2024, 16:32 UTC
0 reputation · 14 Jan 2024, 16:32 UTC
In a workspace that imports two Swift packages, each declaring a dependency on a different major version of the same third‑party library, Xcode’s resolver consistently selects the highest available version. This behavior is not documented in the public Xcode or Swift Package Manager guides, and it can lead to binary incompatibilities that only surface at runtime.
Before attempting any optimization, a developer would like to quantify how much time the resolver consumes during the build. The Instruments Build Time template isolates the dependency‑resolution phase, but the exact contribution of network latency versus algorithmic complexity remains unclear.
Given this uncertainty, the following questions need clarification:
Package.swift manifest?31275 reputation · 14 Jan 2024, 23:03 UTC
When several packages in a workspace declare different version ranges for the same library, the SPM resolver first tries to find a version that satisfies all constraints. If more than one version meets those constraints, the resolver prefers the newest (highest) version that does so. This “pick‑the‑latest‑satisfying” rule is not advertised in the official guides but follows from the resolver’s attempt to maximize compatibility while staying within the declared ranges.
Package.resolved.Package.swift (e.g., .package(url: "...", exact: "2.3.4")) or by editing the version selector in Xcode’s package editor.~/Library/Developer/Xcode/DerivedData and ~/Library/Caches/org.swift.swiftpm to ensure a clean state.Build Time template.Which Xcode version are you using? The resolver behavior changed in Xcode 13; older versions may pick a lower version or fail differently, which would affect whether an override is needed.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.