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 warnings generated by swift proposal SE-0364: Conformances of External Types #14920

Merged
merged 15 commits into from
Jan 22, 2025

Conversation

pmusolino
Copy link
Member

@pmusolino pmusolino commented Jan 20, 2025

Description

This PR fixes a certain number of warnings that started appearing with Swift 6 and Xcode 16, because of the swift proposal SE-0364.

Basically, this proposal introduces a series of warnings that can occur when there is a conformance to a specific protocol for classes declared in a separate module. In Woo Mobile, there are many different modules declared.

One common case, for example, is having a specific struct like BlazeCampaignListItem declared in the Networking layer, but with a conformance to Identifiable declared in the main WooCommerce module.

For example, consider this extension declared in BlazeCampaignListViewModel, while BlazeCampaignListItem is declared in the Networking layer:

/// Conformance to support listing in SwiftUI
extension BlazeCampaignListItem: Identifiable {
    public var id: String {
        campaignID
    }
}

This generates the warning: Extension declares a conformance of imported type 'BlazeCampaignListItem' to imported protocol 'Identifiable'; this will not behave correctly if the owners of 'Networking' introduce this conformance in the future.

To fix this, we should either move this conformance into the relevant module or add the @retroactive attribute. For classes/structs under our control, I moved them into the relevant module. For other classes in modules where we do not have control (e.g., Foundation or UIKit), I added the @retroactive attribute.

Steps to reproduce

  1. Run trunk.
  2. Notice that there are around 10 different warnings regarding this issue.

Testing information

Just run a quick and generic smoke testing, these changes should not introduce a regression.


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@pmusolino pmusolino added the type: technical debt Represents or solves tech debt of the project. label Jan 20, 2025
@pmusolino pmusolino added this to the 21.5 milestone Jan 20, 2025
@dangermattic
Copy link
Collaborator

2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 20, 2025

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr14920-c3385ee
Version21.4
Bundle IDcom.automattic.alpha.woocommerce
Commitc3385ee
App Center BuildWooCommerce - Prototype Builds #12626
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@itsmeichigo itsmeichigo self-assigned this Jan 21, 2025
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

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

Smoke tested on simulator iPhone 16 Pro iOS 18.2:
✅ Blaze campaign list
✅ Stock dashboard card
✅ Creating shipping label package with duplicated name
✅ App navigation bar
✅ Gift card error

And confirmed that these work as expected.
⚠️ Skipped launching site as I could not make this show up in the onboarding task list.

I did a quick search in the warning list and found a few others still around. Should we handle them as well?

Screenshot 2025-01-21 at 10 11 11

@itsmeichigo
Copy link
Contributor

Regarding this message in the PR description:

Just run a quick and generic smoke testing, these changes should not introduce a regression.

I'd appreciate it if you could do smoke testing on the affected changes instead of assuming the changes not introducing any regressions. We cannot be too careful IMO.

@pmusolino
Copy link
Member Author

Thanks, Huong, for the review. I'm not always able to replicate the warnings that you see, so I have to run the app multiple times. I think it's another Xcode issue. For example, at the moment I see just 16 warnings, but I know there are 70+ currently.

In any case, I fixed the fourth warning mentioned in your comment. Please feel free to check again if you see other warnings.

Changes here: af384d3

I'd appreciate it if you could do smoke testing on the affected changes instead of assuming the changes not introducing any regressions. We cannot be too careful IMO.

I did a smoke test on the affected changes (including the new ones), and I didn't find any regressions.

@pmusolino pmusolino requested a review from itsmeichigo January 21, 2025 15:15
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

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

Thanks for the updates!

@pmusolino pmusolino merged commit a73eb6e into trunk Jan 22, 2025
12 checks passed
@pmusolino pmusolino deleted the fix/warnings-due-to-swift-proposal-SE-0364 branch January 22, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: technical debt Represents or solves tech debt of the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants