Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tuist generate when a binary SPM dependency is removed #6298

Merged
merged 1 commit into from
May 20, 2024

Conversation

fortmarek
Copy link
Member

@fortmarek fortmarek commented May 20, 2024

Resolves #6263

Short description πŸ“

As described in the attached issue, tuist generate fails after running tuist 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:

      {
        "basedOn" : null,
        "packageRef" : {
          "identity" : "paypalcheckout-ios",
          "kind" : "remoteSourceControl",
          "location" : "https://github.com/paypal/paypalcheckout-ios",
          "name" : "paypalcheckout-ios"
        },
        "state" : {
          "checkoutState" : {
            "revision" : "da1b998dcab91011b05df139a6819cc58dd45ccd",
            "version" : "1.3.0"
          },
          "name" : "sourceControlCheckout"
        },
        "subpath" : "paypalcheckout-ios"
      }

This means that we still try to parse the paypalcheckout-ios package (even though it was removed from Package.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 🧐

  • Go to fixtures/ios_app_with_spm_dependencies fixture
  • Add .package(url: "https://github.com/paypal/paypalcheckout-ios", from: "1.3.0"), to Tuist/Package.swift
  • Run tuist install && tuist generate
  • Comment out the newly added line
  • Run tuist install && tuist generate again -> the generation should fail with the latest tuist release and it should succeed with the changes in this PR

Contributor checklist βœ…

  • The code has been linted using run mise run lint:fix
  • The change is tested via unit testing or acceptance testing, or both
  • The title of the PR is formulated in a way that is usable as a changelog entry
  • In case the PR introduces changes that affect users, the documentation has been updated

Reviewer checklist βœ…

  • The code architecture and patterns are consistent with the rest of the codebase
  • Reviewer has checked that, if needed, the PR includes the label changelog:added, changelog:fixed, or changelog:changed, and the title is usable as a changelog entry

@fortmarek fortmarek changed the title Fix tuist generate when a binary dependency is removed Fix tuist generate when a binary SPM dependency is removed May 20, 2024
@fortmarek fortmarek added the changelog:fixed PR will be listed in the Fixed section of CHANGELOG label May 20, 2024
@fortmarek fortmarek marked this pull request as ready for review May 20, 2024 10:19
@fortmarek fortmarek requested a review from pepicrft May 20, 2024 10:19
throw PackageInfoMapperError.missingBinaryArtifact(package: packageInfo.key, target: target.name)
}
}
// remote binaries are checked out by SPM in artifacts/<Package.name>/<Target>.xcframework
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Apple for continuing to make developers' life harder every day πŸ˜†

@fortmarek fortmarek merged commit e157ebd into main May 20, 2024
8 checks passed
@fortmarek fortmarek deleted the fix/dependency-removal branch May 20, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:fixed PR will be listed in the Fixed section of CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removing a dependency breaks tuist generate.
2 participants