Skip to content

Conversation

cjwirth
Copy link

@cjwirth cjwirth commented Sep 22, 2025

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 cjwirth changed the title Allow dependencies to exclude themselves from transitive linking Allow excluding dependencies from transitive linking Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally exclude dependencies from being included with transitivelyLinkDependencies
1 participant