Skip to content

Conversation

@EvanBacon
Copy link
Owner

This pull request refactors reference tracking and cascade deletion across the Xcode project model. It centralizes and automates how objects track and remove references to each other, reducing repeated code and making cascade deletion (removing an object and its children only if they are not shared) more robust and easier to maintain. Documentation and tests are also updated to reflect these improvements.

Reference tracking and removal refactor:

  • Centralized the logic for isReferencing and removeReference in AbstractObject, so most subclasses no longer need to implement these themselves. Now, reference tracking is driven by the getObjectProps() pattern, which declares which properties are object references. (src/api/AbstractObject.ts, src/api/AbstractGroup.ts, src/api/AbstractTarget.ts, src/api/PBXNativeTarget.ts, src/api/PBXProject.ts, src/api/XCConfigurationList.ts, [1] [2] [3] [4] [5] [6] [7] [8]

Cascade deletion improvements:

  • Implemented robust removeFromProject() methods for key classes (PBXNativeTarget, XCConfigurationList, PBXTargetDependency, PBXFileSystemSynchronizedRootGroup), ensuring that child objects are only deleted if they are exclusively owned by the parent, preventing accidental deletion of shared objects. (src/api/PBXNativeTarget.ts, src/api/XCConfigurationList.ts, src/api/PBXTargetDependency.ts, src/api/PBXFileSystemSynchronizedRootGroup.ts, [1] [2] [3] [4]

Documentation updates:

  • Expanded CLAUDE.md to document the getObjectProps() pattern and best practices for implementing cascade deletion, making it easier for future contributors to follow and extend the system. Added details on fixture naming and round-trip testing for JSON fixtures. [1] [2]

Testing improvements:

  • Updated and expanded tests for reference tracking and cascade deletion, including new fixtures and improved assertions for getReferrers. (src/api/__tests__/PBXNativeTarget.test.ts, [1] [2] [3]

Type and import cleanups:

  • Removed unused imports and redundant code in several files to streamline the codebase. (src/api/PBXNativeTarget.ts, src/api/PBXNativeTarget.tsL21)

These changes make the codebase more maintainable, safer for large-scale refactoring, and easier for new contributors to understand and extend.

Adds removeReference and removeFromProject methods to key project model classes, ensuring that targets and their exclusively-owned children (such as build phases, dependencies, configuration lists, and file references) are properly removed from the project. Updates PBXNativeTarget, PBXProject, PBXFileSystemSynchronizedRootGroup, PBXTargetDependency, and XCConfigurationList to support safe cascading deletion and reference cleanup. Extends tests to verify correct removal behavior and preservation of shared resources.
Moved isReferencing and removeReference implementations from subclasses to AbstractObject, providing a generic mechanism for reference management. This reduces code duplication and centralizes reference logic for easier maintenance.
Renamed the App Clip fixture file from 009-missing-app-clip-target.pbxproj to 009-expo-app-clip.pbxproj and updated all test references accordingly. Also reformatted some test code for improved readability.
@EvanBacon EvanBacon merged commit 0d2113c into main Jan 12, 2026
1 check passed
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.

2 participants