Skip to content

pack: skip dependencies conditioned off iOS when planning - #442

Open
caquant wants to merge 1 commit into
xtool-org:mainfrom
caquant:pack/platform-conditions
Open

caquant wants to merge 1 commit into
xtool-org:mainfrom
caquant:pack/platform-conditions

Conversation

@caquant

@caquant caquant commented Nov 13, 2026 •

Copy link
Copy Markdown

What does this PR do?

Fixes #433. The planner no longer plans resource bundles for dependencies that are conditioned off iOS. For example, swift-crypto's BoringSSL targets are only built on non-Apple platforms.

swift package describe lists target dependencies without their .when(platforms:) conditions. As a result, the planner walked targets that SwiftPM never builds for iOS, and packing then failed while copying their bundles. The planner now also runs swift package dump-package for each package and reads the conditions from it. It drops target and product dependencies whose platform list excludes ios before walking the graph. Those targets' own dependencies are skipped too.

How was it tested?

Caveats:

  • My machine has Swift 6.3.2. The full package on main (which needs 6.4) doesn't compile there, because of an existing error in XTool.swift. I ran the new tests against PackLib on its own, and ran the end-to-end check on the 1.24.0 tag.
  • I haven't tested this on Linux.

AI tool usage

How much of the code in this PR was AI-assisted? (check one)

  • 0 - No AI was used to write code
  • 1 - I was assisted by AI in writing code. I reviewed the finished result.
  • 2 - I set the AI going and left it to it; nobody has read the result - no review, or AI review only

Summary by CodeRabbit

  • Bug Fixes
    • Package planning now omits target and product dependencies that are unavailable on iOS.

`swift package describe` lists target dependencies without their
platform conditions, so the planner walked targets SwiftPM never builds
for iOS and planned their resource bundles. Read the conditions from
`dump-package` and drop dependencies that exclude iOS.

Fixes xtool-org#433
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The planner now reads SwiftPM package description and manifest output, identifies dependencies excluded on iOS, and removes those dependencies from the package dump. Tests cover platform-based dependency exclusion for iOS and Linux.

Changes: Conditional dependency filtering

Layer / File(s) Summary
Decode conditions and filter target dependencies
Sources/PackLib/Planner.swift, Tests/XToolTests/PlannerTests.swift
PackageManifest reports dependency names excluded on a platform. PackageDump removes those names from target and product dependency arrays. Tests check the reported exclusions for iOS and Linux.
Apply filtering during package dump
Sources/PackLib/Planner.swift
dumpPackage(at:) concurrently obtains describe and dump-package output, decodes both, checks cancellation, and removes dependencies excluded on iOS.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Planner
  participant SwiftPMDescribe as SwiftPM describe
  participant SwiftPMDump as SwiftPM dump-package
  participant PackageManifest
  participant PackageDump
  par Obtain package description
    Planner->>SwiftPMDescribe: Request describe output
    SwiftPMDescribe-->>Planner: Return description
  and Obtain package manifest
    Planner->>SwiftPMDump: Request dump-package output
    SwiftPMDump-->>Planner: Return manifest JSON
  end
  Planner->>PackageManifest: Decode manifest JSON
  PackageManifest-->>Planner: Return dependencies excluded on iOS
  Planner->>PackageDump: Remove excluded dependency names
  PackageDump-->>Planner: Return filtered package dump
Loading

Suggested reviewers: erikbdev, kabiroberai

Merge Risk: Minimal · up to 29459

The change skips dependencies that SwiftPM excludes on iOS, which should fix the swift-crypto packing failure. One narrow edge case remains where a target and a product share a name and have different iOS conditions. It is unlikely to matter in practice and does not block merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the planner now skips dependencies conditioned off iOS. The raw summary confirms Planner.dumpPackage(at:) removes target and product dependencies excluded on iOS, and …
Linked Issues check Passed Issue #433 requires that the planner not plan bundles for targets SwiftPM excludes from iOS builds, and not walk their dependencies. At the reviewed head, Planner.dumpPackage(at:) runs `swift packag…
Out of Scope Changes check Passed The PR changes are limited to Sources/PackLib/Planner.swift (dependency filtering in dumpPackage, manifest decoding, and mutable PackageDump.Target dependency arrays) and `Tests/XToolTests/Plann…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: the planner now skips dependencies conditioned off iOS. The raw summary confirms Planner.dumpPackage(at:) removes target and product dependencies excluded on iOS, and the objectives describe the same change for issue #433. The title is specific and matches the changeset.

Full details: Linked Issues check

Explanation

Issue #433 requires that the planner not plan bundles for targets SwiftPM excludes from iOS builds, and not walk their dependencies. At the reviewed head, Planner.dumpPackage(at:) runs swift package dump-package alongside describe. It then calls dump.removeDependencies(manifest.dependenciesExcluded(onPlatform: "ios")) before the graph is walked. Planner.product(from:...) walks only targetDependencies and productDependencies from the filtered dump. Removing an excluded dependency therefore also prevents walking its own dependencies, and no resource bundle is planned for it. This matches the requested fix (option 1 in the issue). The PR adds PlannerTests for the target, product (with package and module aliases), and byName encodings, and tests the iOS and Linux exclusion results for Crypto. The author reports an end-to-end check on the 1.24.0 tag. I did not run the tests or the end-to-end check. Linux behavior is untested, as the issue also notes. The issue's expected result is met by the code path; the remaining uncertainty is runtime verification.

Full details: Out of Scope Changes check

Explanation

The PR changes are limited to Sources/PackLib/Planner.swift (dependency filtering in dumpPackage, manifest decoding, and mutable PackageDump.Target dependency arrays) and Tests/XToolTests/PlannerTests.swift (new fixture and tests). Each change supports the planner filter for issue #433 or its tests. The summary reports no changes to exported or public declarations. No unrelated change was found in the reviewed evidence.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6dc60eda-7cfd-48aa-9027-f3983a2dc76d
Commits

Reviewing files that changed from the base of the PR and between a2875dd and 294594b.

Files selected for processing: 2

  • Sources/PackLib/Planner.swift
  • Tests/XToolTests/PlannerTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@caquant
caquant marked this pull request as ready for review November 14, 2026 00:05

This branch has not been deployed

No deployments
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.

xtool dev fails on macOS with packages using platform-conditional target dependencies (e.g. swift-crypto)

1 participant