yonaskolb / yonaskolb/XcodeGen

SPM package dependencies on `framework.static` targets cause duplicate symbols

Open
#1,634 0 comments 0 reactions 0 assignees View on GitHub

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
  1. Create two or more targets with type: framework.static
  2. Add the same SPM package dependency to each (without link: false)
  3. Create an app target that depends on both static frameworks, with transitivelyLinkDependencies: true
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.