Skip to content

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

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

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
buildDirectory: _fileSystem.directory(
_platform.buildDirectory(config: _config, fileSystem: _fileSystem),
),
quiet: false,
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.

Note I was able to remove the force here because now prefetchSwiftPackagesForProject only runs if the project has migrated to SwiftPM already so it doesn't get run before here.

Comment on lines +417 to +420
// If the project has not migrated to SwiftPM, we don't need to prefetch Swift packages.
if (!usesSwiftPackageManager || !flutterPluginSwiftPackageInProjectSettings) {
return;
}
Copy link
Copy Markdown
Contributor Author

@vashworth vashworth May 5, 2026

Choose a reason for hiding this comment

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

This is the only change to this functionality. The rest is a copy/paste

);
});

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.

Moved these tests to xcode_project_test.dart

});

group('projectInfo', () {
testUsingContext(
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.

All of this is just formatting. See my next comment to where the tests really start

});
});

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 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!

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.

2 participants