XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Allow excluding dependencies from transitive linking

Open cjwirth opened this issue 4 months ago • 0 comments

Fixes #1580

tl;dr

This change adds a property to the Dependency object such that the dependency will only be included as a dependency of a target if it is declared as a dependency directly in the target itself, and not if it is a transitive dependency.

Description

Let's say you have the following project.yml:

options:
  transitivelyLinkDependencies: true
targets:
  AppTarget:
    type: application
    platform: iOS
    sources: AppTarget
    dependencies:
      - target: FeatureModule
  FeatureModule:
    dependencies:
      - package: SomePackage
        exlcudeFromTransitiveLinking: true

Before this change, both AppTarget and FeatureModule would include SomePackage as a dependency (in fact it would be included in any target that includes FeatureModule as a dependency, even transitively). After this change, it will only be included in FeatureModule.

I'm open to alternatives in both naming and implementation. This just seemed like the easiest way to do it.

Why?

There's more information in the issue #1580, but the tl;dr is that if you have a Swift Package that is an XCFramework that wraps a static library and it gets included in more than one target, you'll get build errors. You should only include that package into one target -- adding it to more brings build errors.

cjwirth avatar Sep 22 '25 08:09 cjwirth