Skip to content

Parse common SwiftPM errors and only fetch Swift packages when project is using SwiftPM#185218

Draft
vashworth wants to merge 16 commits into
flutter:masterfrom
vashworth:issue_184021
Draft

Parse common SwiftPM errors and only fetch Swift packages when project is using SwiftPM#185218
vashworth wants to merge 16 commits into
flutter:masterfrom
vashworth:issue_184021

Conversation

@vashworth
Copy link
Copy Markdown
Contributor

@vashworth vashworth commented Apr 17, 2026

This PR does the following:

  • Moves prefetchSwiftPackages logic from the XcodeProjectInterpreter class to the XcodeBasedProject class so that it can be run per platform (ios, macos)
  • Changes projectPath parameter from a String to XcodeBasedProject
  • Skips prefetchSwiftPackages is project has not been migrated to SwiftPM
  • Adds a call to SwiftPackageManagerIntegrationMigration that prefetches the dependencies
  • Parses common errors that may occur when prefetching SwiftPM dependencies

Addresses #184021.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

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.

@github-actions github-actions Bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. platform-macos Building on or for macOS specifically a: desktop Running on desktop team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Apr 17, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 29, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label Apr 30, 2026
@vashworth vashworth added the CICD Run CI/CD label Apr 30, 2026
@vashworth vashworth marked this pull request as ready for review April 30, 2026 20:27
@vashworth vashworth requested review from a team as code owners April 30, 2026 20:27
Copy link
Copy Markdown
Contributor

@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 introduces a mechanism to parse and report specific Swift Package Manager errors related to Flutter plugins during build and migration processes. It adds a parseError utility in SwiftPackageManager and integrates it into the iOS build and migration logic. Review feedback identifies a logic error in xcodeproj.dart where the incorrect directory is used to find the Flutter project, and suggests using allMatches instead of firstMatch in the error parser to ensure all potential plugin errors are evaluated.

Comment thread packages/flutter_tools/lib/src/ios/xcodeproj.dart Outdated
Comment thread packages/flutter_tools/lib/src/macos/swift_package_manager.dart Outdated
@hellohuanlin hellohuanlin marked this pull request as draft April 30, 2026 21:42
@flutter-dashboard
Copy link
Copy Markdown

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions Bot removed the CICD Run CI/CD label May 1, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 1, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 1, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 1, 2026
@vashworth vashworth marked this pull request as ready for review May 1, 2026 19:12
Copy link
Copy Markdown
Contributor

@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 enhances Swift Package Manager integration by introducing guided error messages for common plugin configuration issues. It implements a parsing mechanism for SwiftPM error output and updates the prefetchSwiftPackages method with a force flag. The migration process is also updated to include a prefetch step with specific error handling. Feedback suggests refining the error-matching regular expressions to support common subdirectories and versioned plugin directories in the pub cache.

Comment thread packages/flutter_tools/lib/src/macos/swift_package_manager.dart
Comment thread packages/flutter_tools/lib/src/macos/swift_package_manager.dart
});
});

testWithoutContext(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These tests are copy/pasted with some slight tweaks since it's a new class.

);
});

testWithoutContext('prefetchSwiftPackages can run for both platforms', () async {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a new test

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 5, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 5, 2026
@vashworth vashworth added the CICD Run CI/CD label May 5, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 5, 2026
@vashworth vashworth added the CICD Run CI/CD label May 6, 2026
@github-actions github-actions Bot removed the CICD Run CI/CD label May 6, 2026
@hellohuanlin
Copy link
Copy Markdown
Contributor

Saw you are still updating this PR. Just double check if this is ready for review?

@vashworth vashworth added the CICD Run CI/CD label May 6, 2026
@flutter-dashboard
Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@vashworth
Copy link
Copy Markdown
Contributor Author

Saw you are still updating this PR. Just double check if this is ready for review?

Let me make sure the tests pass first

@github-actions github-actions Bot removed the CICD Run CI/CD label May 6, 2026
@vashworth vashworth added the CICD Run CI/CD label May 6, 2026
@vashworth vashworth requested a review from hellohuanlin May 6, 2026 18:18
@hellohuanlin
Copy link
Copy Markdown
Contributor

Is PR description up to date? If not, could you update for the ease of review and for future reference?

@vashworth vashworth changed the title Parse common SwiftPM errors Parse common SwiftPM errors and only fetch Swift packages when project is using SwiftPM May 7, 2026
@vashworth
Copy link
Copy Markdown
Contributor Author

Is PR description up to date? If not, could you update for the ease of review and for future reference?

Done. This PR has kind of evolved. Let me know if you want me to break it up.

@hellohuanlin
Copy link
Copy Markdown
Contributor

Is PR description up to date? If not, could you update for the ease of review and for future reference?

Done. This PR has kind of evolved. Let me know if you want me to break it up.

Yes, breaking it up would make the review easier, and also helps future readers. Thank you!

pull Bot pushed a commit to SaintPatricks-Github-Coinpot-Club/flutter that referenced this pull request May 12, 2026
…Interpreter (flutter#186378)

Pass `XcodeBasedProject` instead of the project path string.

This will enable us to be able to get more information about the project
(other than just the project path) from places in `xcodeproj.dart`.
Needed for flutter#185218,
https://github.com/flutter/flutter/pull/186006/changes#r3191012567

## 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].
- [ ] 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].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**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
@LongCatIsLooong LongCatIsLooong marked this pull request as draft May 14, 2026 21:33
gaaclarke pushed a commit to gaaclarke/flutter that referenced this pull request May 21, 2026
This PR moves the logic for `prefetchSwiftPackages` from the
`XcodeProjectInterpreter` class to the `XcodeBasedProject` class so that
it can be run per platform

Incremental step toward flutter#185218.

## 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].
- [ ] 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].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD platform-ios iOS applications specifically platform-macos Building on or for macOS specifically team-ios Owned by iOS platform team team-macos Owned by the macOS platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants