Parse scheme file with XML parser for SwiftPM migrator#184525
Conversation
There was a problem hiding this comment.
Code Review
This pull request transitions the SwiftPackageManagerIntegrationMigration from line-based string manipulation to XML parsing for updating Xcode schemes. It also updates the migration detection criteria and includes a new test case for varied XML spacing. The review feedback highlights the necessity of XML-escaping attribute values like BuildableName, BlueprintName, and ReferencedContainer when they are re-inserted into string templates to prevent the generation of malformed XML.
| if (buildableNameAttr == null) { | ||
| throw Exception('Failed to parse ${schemeFile.basename}: Could not find BuildableName.'); | ||
| } | ||
| final buildableName = 'BuildableName = "$buildableNameAttr"'; |
There was a problem hiding this comment.
The buildableNameAttr value obtained from getAttribute is already decoded. When injecting it back into a string-based XML template, special characters like & or " must be re-encoded to ensure the resulting XML is valid. If a target name contains a double quote, it will break the XML structure.
| final buildableName = 'BuildableName = "$buildableNameAttr"'; | |
| final buildableName = 'BuildableName = "${buildableNameAttr.replaceAll('&', '&').replaceAll('"', '"')}"'; |
| if (blueprintNameAttr == null) { | ||
| throw Exception('Failed to parse ${schemeFile.basename}: Could not find BlueprintName.'); | ||
| } | ||
| final blueprintName = 'BlueprintName = "$blueprintNameAttr"'; |
There was a problem hiding this comment.
Similar to buildableNameAttr, the blueprintNameAttr value should be XML-escaped before being placed into the template to prevent generating invalid XML if the target name contains special characters.
| final blueprintName = 'BlueprintName = "$blueprintNameAttr"'; | |
| final blueprintName = 'BlueprintName = "${blueprintNameAttr.replaceAll('&', '&').replaceAll('"', '"')}"'; |
| 'Failed to parse ${schemeFile.basename}: Could not find ReferencedContainer.', | ||
| ); | ||
| } | ||
| final referencedContainer = 'ReferencedContainer = "$referencedContainerAttr"'; |
There was a problem hiding this comment.
The referencedContainerAttr value should be XML-escaped to ensure the generated XML remains valid even if the container path contains special characters.
| final referencedContainer = 'ReferencedContainer = "$referencedContainerAttr"'; | |
| final referencedContainer = 'ReferencedContainer = "${referencedContainerAttr.replaceAll('&', '&').replaceAll('"', '"')}"'; |
| $buildableName | ||
| $blueprintName | ||
| $referencedContainer | ||
| $referencedContainer> |
There was a problem hiding this comment.
Nope, it's closed in the next line with </BuildableReference>
|
A reason for requesting a revert of flutter/flutter/184525 could |
|
Reason for revert: tree breakage. |
flutter/flutter@9cd60b5...a0924c7 2026-04-07 [email protected] Reland "[data_assets] Cleanup tests" (flutter/flutter#184714) 2026-04-07 [email protected] Use the WindowRegistry in the multiple_windows example app (flutter/flutter#184579) 2026-04-07 [email protected] Introduce command to build a swift package for SwiftPM add to app integration (flutter/flutter#184660) 2026-04-07 [email protected] Have `flutter create` create a pubspec.lock to ensure pinned versions are being used. (flutter/flutter#175352) 2026-04-07 [email protected] [widgets/raw_menu_anchor.dart] Always call onClose and onCloseRequested on descendants before parent. (flutter/flutter#182357) 2026-04-07 [email protected] `WindowsPlugin` should not crash when ffiPlugin enabled (flutter/flutter#184695) 2026-04-06 [email protected] Use full goto.google.com hostname for go/ links (flutter/flutter#184679) 2026-04-06 [email protected] Apply rect clipping to surface views (flutter/flutter#184471) 2026-04-06 [email protected] [A11y] Allow percentage strings like "50%" as `SemanticsValue` for `ProgressIndicator` (flutter/flutter#183670) 2026-04-06 [email protected] Fix invisible accessibility element before scroll view (flutter/flutter#184155) 2026-04-06 [email protected] Roll Skia from 163dfdf500c7 to e264d870a380 (2 revisions) (flutter/flutter#184674) 2026-04-06 [email protected] Keep last character obscured when toggling obscureText (flutter/flutter#183488) 2026-04-06 [email protected] Parse scheme file with XML parser for SwiftPM migrator (flutter/flutter#184525) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Make scheme parsing more forgiving of whitespace differences. Fixes flutter#183029. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). 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. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Make scheme parsing more forgiving of whitespace differences.
Fixes #183029.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot 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.