Add delete support for XCLocalSwiftPackageReference#1044
Open
Kosikowski wants to merge 2 commits intotuist:mainfrom
Open
Add delete support for XCLocalSwiftPackageReference#1044Kosikowski wants to merge 2 commits intotuist:mainfrom
Kosikowski wants to merge 2 commits intotuist:mainfrom
Conversation
The delete method in PBXObjects was missing support for XCLocalSwiftPackageReference, causing local package references to remain as orphaned objects in the pbxproj when switching from local back to remote packages. This adds handling for localSwiftPackageReferences in the delete method, matching the existing pattern for remoteSwiftPackageReferences.
Tests verify that: - Adding a local package reference to PBXProj works correctly - Deleting a local package reference removes it from PBXProj - Deleting one of multiple local packages removes only the correct one - Deleting an object not in the project is a no-op
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.
Add delete support for XCLocalSwiftPackageReference
The
deletemethod inPBXObjectswas missing support forXCLocalSwiftPackageReference, causing local package references to remain as orphaned objects in the pbxproj when switching from local back to remote packages.This adds handling for
localSwiftPackageReferencesin the delete method, matching the existing pattern forremoteSwiftPackageReferences.Short description 📝
When programmatically managing Swift package dependencies in Xcode projects, switching a local package reference back to a remote package reference leaves orphaned
XCLocalSwiftPackageReferenceobjects in the project file. This occurs becausePBXObjects.delete(reference:)handlesremoteSwiftPackageReferencesbut notlocalSwiftPackageReferences.This PR adds the missing delete support for local Swift package references, ensuring clean removal of these objects when they are no longer needed.
Solution 📦
The solution follows the existing pattern established for other object types in the
delete(reference:)method. Specifically, it mirrors the implementation forremoteSwiftPackageReferences:Alternative approaches considered:
none
Implementation 👩💻👨💻
localSwiftPackageReferenceshandling toPBXObjects.delete(reference:)methodXCLocalSwiftPackageReference:test_add_addsObjectToPBXProj— verifies adding works correctlytest_delete_removesObjectFromPBXProj— verifies deletion works correctlytest_delete_removesCorrectObject_whenMultipleExist— verifies only the targeted object is removedtest_delete_doesNothing_whenObjectNotInProj— verifies safe behaviour for non-existent objectsTesting 🧪
All tests pass locally: