Add Swift Package helper methods and fix test runner issue#45
Merged
Add Swift Package helper methods and fix test runner issue#45
Conversation
This PR addresses GitHub issue #31 by adding convenient helper methods for working with Swift packages, and fixes a pre-existing Bun test runner issue. ## New Helper Methods **PBXProject:** - `addPackageReference(ref)` - Add package reference to project - `getPackageReference(identifier)` - Find package by URL or path - `addRemoteSwiftPackage(opts)` - Create and add remote package - `addLocalSwiftPackage(opts)` - Create and add local package **PBXNativeTarget:** - `addSwiftPackageProduct(opts)` - Full wiring: creates product dep, adds to target, creates build file, adds to frameworks phase - `getSwiftPackageProductDependencies()` - Get all package deps - `removeSwiftPackageProduct(dep)` - Remove with cleanup **PBXBuildFile:** - `createFromProductRef(opts)` - Create build file for Swift packages ## Bug Fixes - Fixed `fileRef` to be optional in PBXBuildFile (required for SPM) - Fixed Bun test runner "export not found" error by using proper `export type` for AnyBuildPhase in index.ts - Fixed circular dependency in utils/paths.ts by importing directly from source files instead of index ## Tests Added comprehensive tests for all new functionality (50 new tests). Closes #31 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Cast json.objects access to any for property access. Co-Authored-By: Claude Opus 4.5 <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.
Summary
New Helper Methods
PBXProject:
addPackageReference(ref)- Add a package reference topackageReferencesgetPackageReference(identifier)- Find package by URL (remote) or path (local)addRemoteSwiftPackage(opts)- Create and add remote package in one calladdLocalSwiftPackage(opts)- Create and add local package in one callPBXNativeTarget:
addSwiftPackageProduct(opts)- Full wiring: creates product dependency, adds to target, creates build file, adds to frameworks phasegetSwiftPackageProductDependencies()- Returns all package product deps for targetremoveSwiftPackageProduct(dep)- Removes product dep and cleans up build filePBXBuildFile:
createFromProductRef(opts)- Creates build file for Swift package products (nofileRefrequired)Usage Example
Bug Fixes
fileRefoptional inPBXBuildFileJSON type (Swift package build files only haveproductRef)export type { AnyBuildPhase }instead of value exportutils/paths.tsby importing directly from source filesTest plan
Closes #31
🤖 Generated with Claude Code