yonaskolb / yonaskolb/XcodeGen
SPM package dependencies on `framework.static` targets cause duplicate symbols
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 8.8k
- Forks
- 908
- Avg merge
- 17d 14h
- Merged PRs (30d)
- 2
Description
When a framework.static target declares an SPM package dependency without explicit link: false, XcodeGen adds the package to both packageProductDependencies and the Frameworks build phase. This causes duplicate symbol errors at link time when multiple static framework targets depend on the same package, because Xcode bakes the package's object code into each static framework independently.
The existing logic in PBXProjGenerator.swift correctly handles library.static (staticLibrary) targets — it excludes them from the Frameworks build phase by default. But framework.static (staticFramework) targets are not covered by the same check, so they get the default linking behavior intended for dynamic frameworks and applications.
To reproduce
- Create two or more targets with
type: framework.static - Add the same SPM package dependency to each (without
link: false) - Create an app target that depends on both static frameworks, with
transitivelyLinkDependencies: true - Generate and build — the linker reports duplicate symbols from the shared package
Workaround
Setting link: false on each package dependency in static framework targets avoids the issue, but this must be maintained manually for every package on every static framework target.
Expected behavior
framework.static targets should be treated like library.static targets for package linking: packages should not be added to the Frameworks build phase, and should not be added to packageProductDependencies (since Xcode embeds package object code into the static framework from that list). Instead, packages should be added as build-order-only PBXTargetDependency entries, which is sufficient for module resolution within the project.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in PBXProjGenerator.swift, focusing on the existing staticLibrary handling and the package dependency logic for staticFramework targets. Reproduce the issue with multiple framework.static targets sharing an SPM package, then verify that packages are omitted from the Frameworks build phase and packageProductDependencies while build-order-only PBXTargetDependency entries remain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100