fix: add robust model removal from project #33
Merged
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.
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:
isReferencingandremoveReferenceinAbstractObject, so most subclasses no longer need to implement these themselves. Now, reference tracking is driven by thegetObjectProps()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:
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:
CLAUDE.mdto document thegetObjectProps()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:
getReferrers. (src/api/__tests__/PBXNativeTarget.test.ts, [1] [2] [3]Type and import cleanups:
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.