Fix tuist generate when a binary SPM dependency is removed #6298
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.
Resolves #6263
Short description π
As described in the attached issue,
tuist generate
fails after runningtuist install
when a dependency was removed.This is because
swift package resolve
does remove the reference to the binary in the.build/workspace-state.json
file, but the following is kept:This means that we still try to parse the
paypalcheckout-ios
package (even though it was removed fromPackage.swift
) but we would no longer find a binary for it.To handle this more gracefully, we try to use a default path for the binary. If the target is not referenced by any downstream target, the generation will succeed. If the target is referenced, the generation will fail with an error that the binary could not be found.
How to test the changes locally π§
fixtures/ios_app_with_spm_dependencies
fixture.package(url: "https://github.com/paypal/paypalcheckout-ios", from: "1.3.0"),
toTuist/Package.swift
tuist install && tuist generate
tuist install && tuist generate
again -> the generation should fail with the latest tuist release and it should succeed with the changes in this PRContributor checklist β
mise run lint:fix
Reviewer checklist β
changelog:added
,changelog:fixed
, orchangelog:changed
, and the title is usable as a changelog entry