Skip to content

SPM package dependencies on framework.static targets cause duplicate symbols #1634

Description

@daltonclaybrook

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions