Skip to content

Commit d3dd774

Browse files
authored
Show warning when plugins do not support SwiftPM (flutter#182506)
Provides a warning with a list of plugins that do not support SwiftPM. This is displayed to the app developer. It then recommends they reach out to the plugin maintainers to adopt SwiftPM. Example: ``` The following plugins do not support Swift Package Manager for ios: - sqflite_sqlcipher - sign_in_with_apple - permission_handler_apple - flutter_secure_storage - flutter_inappwebview_ios - flutter_facebook_auth - flutter_contacts - flutter_config - fast_contacts This will not be supported in a future version of Flutter. Please contact the plugin maintainers to request Swift Package Manager adoption. ``` Fixes flutter#152038. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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 [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
1 parent 9895434 commit d3dd774

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class DarwinDependencyManagement {
148148
var pluginCount = 0;
149149
var swiftPackageCount = 0;
150150
var cocoapodCount = 0;
151+
final Set<String> cocoapodOnlyPlugins = {};
151152
for (final Plugin plugin in _plugins) {
152153
if (plugin.platforms[platform.name] == null) {
153154
continue;
@@ -179,6 +180,10 @@ class DarwinDependencyManagement {
179180
cocoapodCount += 1;
180181
}
181182

183+
if (cocoaPodsCompatible && !swiftPackageManagerCompatible) {
184+
cocoapodOnlyPlugins.add(plugin.name);
185+
}
186+
182187
// If not using Swift Package Manager and plugin does not have podspec
183188
// but does have a Package.swift, throw an error. Otherwise, it'll error
184189
// when it builds.
@@ -205,6 +210,15 @@ class DarwinDependencyManagement {
205210
}
206211
}
207212

213+
if (hostPlatformIsMacOS && cocoapodOnlyPlugins.isNotEmpty) {
214+
_logger.printWarning(
215+
'The following plugins do not support Swift Package Manager for ${platform.name}:\n'
216+
' - ${cocoapodOnlyPlugins.join('\n - ')}\n'
217+
'This will become an error in a future version of Flutter. Please contact the plugin '
218+
'maintainers to request Swift Package Manager adoption.',
219+
);
220+
}
221+
208222
// Only show warnings to remove CocoaPods if the project is using Swift
209223
// Package Manager, has already been migrated to have SPM integration, and
210224
// all plugins are Swift Packages.

packages/flutter_tools/test/general.shard/macos/darwin_dependency_management_test.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ void main() {
6666
);
6767
await dependencyManagement.setUp(platform: platform);
6868
expect(swiftPackageManager.generated, isTrue);
69-
expect(testLogger.warningText, isEmpty);
69+
expect(
70+
testLogger.warningText,
71+
contains(
72+
'The following plugins do not support Swift Package Manager for '
73+
'${platform.name}:\n'
74+
' - cocoapod_plugin_1\n'
75+
'This will become an error in a future version of Flutter. Please contact the '
76+
'plugin maintainers to request Swift Package Manager adoption.\n',
77+
),
78+
);
7079
expect(testLogger.statusText, isEmpty);
7180
expect(cocoaPods.podfileSetup, isTrue);
7281
expect(
@@ -459,7 +468,10 @@ void main() {
459468
);
460469
await dependencyManagement.setUp(platform: platform);
461470
expect(swiftPackageManager.generated, isTrue);
462-
expect(testLogger.warningText, isEmpty);
471+
expect(
472+
testLogger.warningText,
473+
contains('The following plugins do not support Swift Package Manager'),
474+
);
463475
expect(testLogger.statusText, isEmpty);
464476
expect(cocoaPods.podfileSetup, isTrue);
465477
expect(
@@ -526,7 +538,10 @@ void main() {
526538
);
527539
await dependencyManagement.setUp(platform: platform);
528540
expect(swiftPackageManager.generated, isTrue);
529-
expect(testLogger.warningText, isEmpty);
541+
expect(
542+
testLogger.warningText,
543+
contains('The following plugins do not support Swift Package Manager'),
544+
);
530545
expect(testLogger.statusText, isEmpty);
531546
expect(cocoaPods.podfileSetup, isTrue);
532547
expect(
@@ -580,7 +595,10 @@ void main() {
580595
);
581596
await dependencyManagement.setUp(platform: platform);
582597
expect(swiftPackageManager.generated, isFalse);
583-
expect(testLogger.warningText, isEmpty);
598+
expect(
599+
testLogger.warningText,
600+
contains('The following plugins do not support Swift Package Manager'),
601+
);
584602
expect(testLogger.statusText, isEmpty);
585603
expect(cocoaPods.podfileSetup, isTrue);
586604
expect(

0 commit comments

Comments
 (0)