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#182246auto-submit[bot] merged 13 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?
| ' .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
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
| /// | ||
| /// This looks for common patterns used to declare a FlutterFramework dependency: | ||
| /// - `.package(name: "FlutterFramework", path: "../FlutterFramework")` - package dependency | ||
| /// - `.product(name: "FlutterFramework", package: "FlutterFramework")` - target dependency |
There was a problem hiding this comment.
I'm not familiar with SwiftPM, but can target dependency be just a string (if no naming conflict)? Something like:
dependencies: [
"FlutterFramework",
]
There was a problem hiding this comment.
This seems to be outstanding? @vashworth is this a possible case that we should watch out?
| class SwiftPackageManagerPluginValidationResult { | ||
| SwiftPackageManagerPluginValidationResult({ | ||
| required this.hasPodspec, | ||
| required this.hasPackageSwift, |
There was a problem hiding this comment.
Nit: I assume this refers to "Package.swift" file? How about hasSwiftPMManifest?
| final bool hasFlutterFrameworkDependency; | ||
| final List<String> validationMessages; | ||
|
|
||
| bool get isFullyCompatible => hasPackageSwift && hasFlutterFrameworkDependency; |
There was a problem hiding this comment.
what does "fully compatible" mean? (and what is "partially" compatible? the ones without
"FlutterFramework" dependency?
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart
Outdated
Show resolved
Hide resolved
8272e14 to
0080a40
Compare
# Conflicts: # packages/flutter_tools/test/general.shard/macos/darwin_dependency_management_test.dart
…ility to their plugin (flutter/flutter#182246)
…ility to their plugin (flutter/flutter#182246)
…ility to their plugin (flutter/flutter#182246)
…ility to their plugin (flutter/flutter#182246)
…ility to their plugin (flutter/flutter#182246)
…ility to their plugin (flutter/flutter#182246)
…ility to their plugin (flutter/flutter#182246)
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.