Skip to content

Support build files that reference a Swift package product - #143

Open
Ryan Zulkoski (rzulkoski) wants to merge 1 commit into
Lightricks:mainfrom
hallow-inc:fix/swift-package-product-build-files
Open

Support build files that reference a Swift package product#143
Ryan Zulkoski (rzulkoski) wants to merge 1 commit into
Lightricks:mainfrom
hallow-inc:fix/swift-package-product-build-files

Conversation

@rzulkoski

Copy link
Copy Markdown
Contributor

What & why

A PBXBuildFile references either a file (fileRef) or a Swift package product (productRef, an XCSwiftPackageProductDependency). add_build_file assumed the former: it warned "Trying to add a build file without any file reference" and returned whenever fileRef was nil, silently dropping any build file that links a package product (e.g. a package framework in a Frameworks build phase) during a merge.

This warns and returns only when both fileRef and productRef are absent, and:

  • dedups productRef build files by their full product reference (two products from different packages may share a product name);
  • reuses an equivalent package product dependency already present in the same target rather than duplicating it — a dependency is shared within a target by its packageProductDependencies entry and the linking build file's productRef, but Xcode keeps a separate dependency object per target.

Testing

Adds specs for productRef build files, the shared within-target dependency, per-target separation, and same-name-different-package products; full suite green.

Disclosure

Developed with Claude Code, including several rounds of automated adversarial review before submission.

🤖 Generated with Claude Code

A PBXBuildFile references either a file (fileRef) or a Swift package product
(productRef, an XCSwiftPackageProductDependency). add_build_file assumed the
former: it warned "Trying to add a build file without any file reference" and
returned whenever fileRef was nil, silently dropping any build file that links
a package product (e.g. a package framework in a Frameworks build phase).

Warn and return only when both fileRef and productRef are absent, and dedup
productRef build files by their full product reference (two products from
different packages may share a product name). A package product dependency is
shared within a target by its packageProductDependencies entry and the
productRef of the build file that links it, so reuse an equivalent dependency
already present in the same target rather than adding a duplicate (scoped per
target, since Xcode keeps a separate dependency object per target).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant