Prompt plugin authors to add Swift Package Manager compatibility to their plugin#182246
Prompt plugin authors to add Swift Package Manager compatibility to their plugin#182246okorohelijah wants to merge 10 commits intoflutter:masterfrom
Conversation
|
The doc for migrating to spm doesnt seem to include adding the FlutterFramework dependency. I plan on updating it |
There was a problem hiding this comment.
Code Review
This pull request introduces a validation check to prompt plugin authors to add Swift Package Manager (SPM) compatibility for their iOS and macOS plugins. The check runs when refreshPluginsList is called for a plugin's example app. It verifies if a plugin with a podspec also has a Package.swift file, and if so, whether it correctly depends on FlutterFramework. Warnings are displayed to guide plugin authors on how to add or fix their SPM support. The changes include new logic in flutter_plugins.dart and plugins.dart, along with corresponding unit tests.
vashworth
left a comment
There was a problem hiding this comment.
Can you move all logic into DarwinDependencyManagement?
There was a problem hiding this comment.
I think this could be simplified by adding the warning to _evaluatePluginsAndPrintWarnings, which already checks if the plugin is SwiftPM/CocoaPods compatible.
I'd do something like
Future<({int totalCount, int swiftPackageCount, int podCount})> _evaluatePluginsAndPrintWarnings({
...
}) async {
String? pluginFromExampleApp = _loadPluginFromExampleProject(...);
for (final Plugin plugin in _plugins) {
...
if (!swiftPackageManagerCompatible && !cocoaPodsCompatible) {
continue;
}
if (plugin.name == pluginFromExampleApp) {
if (swiftPackageManagerCompatible && !_hasFlutterFrameworkDependency()) {
_logger.printWarning(...)
} else if (!swiftPackageManagerCompatible) {
_logger.printWarning(...)
}
}
}
}There was a problem hiding this comment.
_evaluatePluginsAndPrintWarnings operates on the app's dependency plugins during every build and targets app developers while the validation only fires for plugin example apps, targets the parent plugin being developed, and does a deeper content analysis of the Package.swift (checking for FlutterFramework dependency declarations while filtering out comments). I thought merging them could be be a mix of 2 different things so I kept them separate for clarity wdyt?
| ' .package(name: "FlutterFramework", path: "../FlutterFramework")\n' | ||
| 'And add FlutterFramework as a target dependency:\n' | ||
| ' .product(name: "FlutterFramework", package: "FlutterFramework")\n' | ||
| 'See $kSwiftPackageManagerDocsUrl for more information.', |
There was a problem hiding this comment.
Let's wait for flutter/website#12979 to land, so we can point to the docs
Prompt plugin authors to add Swift Package Manager compatibility to their plugin
Fixes #148222
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
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.