Support build files that reference a Swift package product - #143
Open
Ryan Zulkoski (rzulkoski) wants to merge 1 commit into
Open
Support build files that reference a Swift package product#143Ryan Zulkoski (rzulkoski) wants to merge 1 commit into
Ryan Zulkoski (rzulkoski) wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
A
PBXBuildFilereferences either a file (fileRef) or a Swift package product (productRef, anXCSwiftPackageProductDependency).add_build_fileassumed the former: it warned "Trying to add a build file without any file reference" and returned wheneverfileRefwas 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
fileRefandproductRefare absent, and:productRefbuild files by their full product reference (two products from different packages may share a product name);packageProductDependenciesentry and the linking build file'sproductRef, 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