这是indexloc提供的服务,不要输入任何密码
Skip to content

Disable SwiftPM for xcode-analyze #9666

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stuartmorgan-g
Copy link
Contributor

Until flutter/flutter#172427 is resolved, xcode-analyze doesn't work as desired with SwiftPM enabled (it analyzes only the test code, not the plugin code). To avoid losing analysis coverage in the meantime, this disabled SwiftPM temporarily while running analysis.

This PR also updates build-examples to use the newer pubspec-based config option to set the SwiftPM flag state instead of setting global state, to avoid future issues where we are unintentionally bleeding flag changes across different tests, and to make local runs not impact developer machine state.

To unit test this functionality, this adds a new feature to the existing process mock system that allows running an arbitrary test callback at the ponit where a process is being run, which in this case allows reading the temporarily-modified pubspec contents at the right point in the command execution.

Fixes flutter/flutter#171442

Pre-Review Checklist

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Until flutter/flutter#172427 is resolved,
`xcode-analyze` doesn't work as desired with SwiftPM enabled (it
analyzes only the test code, not the plugin code). To avoid losing
analysis coverage in the meantime, this disabled SwiftPM temporarily
while running analysis.

This PR also updates `build-examples` to use the newer pubspec-based
config option to set the SwiftPM flag state instead of setting global
state, to avoid future issues where we are unintentionally bleeding flag
changes across different tests, and to make local runs not impact
developer machine state.

To unit test this functionality, this adds a new feature to the existing
process mock system that allows running an arbitrary test callback at
the ponit where a process is being run, which in this case allows
reading the temporarily-modified pubspec contents at the right point in
the command execution.

Fixes flutter/flutter#171442
@stuartmorgan-g stuartmorgan-g requested a review from vashworth July 23, 2025 15:12
@@ -150,23 +144,6 @@ class BuildExamplesCommand extends PackageLoopingCommand {
'were specified. At least one platform must be provided.');
throw ToolExit(_exitNoPlatformFlags);
}

switch (_swiftPackageManagerFeatureConfig) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change from the flag to the pubspec config does mean that we are delaying stable testing of SwiftPM in this repo longer, since the pubspec config won't do anything on current stable, but since we were already accidentally not testing it on stable anyway even though we could have been, I don't think delaying a bit longer is a big deal. And unlike the old code, this version will not require us to remember to turn it on for stable later, it'll just start working as soon as stable gets the config feature.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves the tooling's robustness by moving SwiftPM configuration from global state to temporary pubspec.yaml modifications, enhancing test reliability. The new runCallback in the mock process runner is a smart way to test these changes.

My review focuses on a few areas:

  • Robustness: I've suggested using try...finally blocks to ensure pubspec.yaml is always restored, even if errors occur.
  • Maintainability: I've identified opportunities to simplify the YAML editing logic and to refactor duplicated test code into helper functions.

These changes will make the tooling more resilient and easier to maintain.

@stuartmorgan-g
Copy link
Contributor Author

Hm, this is blocked on flutter/flutter#154365, unless we turn of analysis for the whole maps package (or hard-code special handling of the ios15 example apps somewhere, or build a generic system for opting specific examples out of tests rather than whole packages).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[packages] Xcode analysis failing on stable only
1 participant