Skip to content

Commit 8aa4b3f

Browse files
authored
Collect analytics about SwiftPM errors and warnings (flutter#191746)
Fixes flutter#181560. ## 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]. - [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]. 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
1 parent 5c1c754 commit 8aa4b3f

11 files changed

Lines changed: 1719 additions & 67 deletions

‎packages/flutter_tools/lib/src/ios/mac.dart‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ Future<XcodeBuildResult> buildXcodeProject({
149149
fileSystem: globals.fs,
150150
plistParser: globals.plistParser,
151151
config: globals.config,
152+
analytics: globals.analytics,
153+
hostPlatform: globals.platform,
154+
operatingSystemUtils: globals.os,
155+
flutterVersion: globals.flutterVersion,
156+
reportCrashes: !await globals.isRunningOnBot
152157
),
153158
SwiftPackageManagerGitignoreMigration(project, globals.logger),
154159
MetalAPIValidationMigrator.ios(app.project, globals.logger),
@@ -182,6 +187,7 @@ Future<XcodeBuildResult> buildXcodeProject({
182187
fileSystem: globals.fs,
183188
logger: globals.logger,
184189
cocoapods: globals.cocoaPods,
190+
analytics: globals.analytics,
185191
featureFlags: featureFlags,
186192
);
187193

@@ -912,6 +918,7 @@ Future<void> diagnoseXcodeBuildFailure(
912918
platform: platform,
913919
logger: logger,
914920
fileSystem: fileSystem,
921+
analytics: analytics,
915922
device: device,
916923
);
917924

@@ -1138,6 +1145,7 @@ Future<bool> _handleIssues(
11381145
required FlutterDarwinPlatform platform,
11391146
required Logger logger,
11401147
required FileSystem fileSystem,
1148+
required Analytics analytics,
11411149
Device? device,
11421150
}) async {
11431151
var requiresProvisioningProfile = false;
@@ -1228,6 +1236,11 @@ Future<bool> _handleIssues(
12281236
final bool usesCocoapods = xcodeProject.podfile.existsSync();
12291237
final bool usesSwiftPackageManager = xcodeProject.usesSwiftPackageManager;
12301238
if (usesCocoapods && usesSwiftPackageManager) {
1239+
for (final module in duplicateModules) {
1240+
analytics.send(
1241+
Event.appleUsageEvent(workflow: 'duplicate-modules-build-failure', parameter: module),
1242+
);
1243+
}
12311244
logger.printError(
12321245
'Your project uses both CocoaPods and Swift Package Manager, which can '
12331246
'cause the above error. It may be caused by there being both a CocoaPod '

‎packages/flutter_tools/lib/src/macos/build_macos.dart‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ Future<void> buildMacOS({
127127
fileSystem: globals.fs,
128128
plistParser: globals.plistParser,
129129
config: globals.config,
130+
analytics: globals.analytics,
131+
hostPlatform: globals.platform,
132+
operatingSystemUtils: globals.os,
133+
flutterVersion: globals.flutterVersion,
134+
reportCrashes: !await globals.isRunningOnBot
130135
),
131136
SwiftPackageManagerGitignoreMigration(flutterProject, globals.logger),
132137
MetalAPIValidationMigrator.macos(flutterProject.macos, globals.logger),
@@ -142,6 +147,7 @@ Future<void> buildMacOS({
142147
fileSystem: globals.fs,
143148
logger: globals.logger,
144149
cocoapods: globals.cocoaPods,
150+
analytics: globals.analytics,
145151
featureFlags: featureFlags,
146152
);
147153

‎packages/flutter_tools/lib/src/macos/cocoapods.dart‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,13 @@ class CocoaPods {
540540
),
541541
);
542542
if (missingPluginSupportsSwiftPM) {
543+
_analytics.send(
544+
Event.appleUsageEvent(
545+
workflow: 'cocoapod-swiftpm-interdependency-failure',
546+
parameter: requiringPlugin,
547+
result: missingPlugin,
548+
),
549+
);
543550
return 'Error: A dependency conflict has occurred because $requiringPlugin uses CocoaPods while '
544551
'$missingPlugin uses Swift Package Manager. Please contact the $requiringPlugin '
545552
'maintainers to request Swift Package Manager adoption.\n\n'

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class DarwinDependencyManagement {
176176
required FileSystem fileSystem,
177177
required Logger logger,
178178
required CocoaPods? cocoapods,
179+
required Analytics analytics,
179180
required FeatureFlags featureFlags,
180181
}) async {
181182
final bool projectUsesSwiftPM =
@@ -230,6 +231,7 @@ class DarwinDependencyManagement {
230231
cocoapodOnlyPlugins: cocoapodOnlyPlugins,
231232
logger: logger,
232233
platform: platform,
234+
analytics: analytics,
233235
);
234236

235237
await _printRemoveCocoapodIntegrationMessage(
@@ -287,6 +289,7 @@ class DarwinDependencyManagement {
287289
required List<String> cocoapodOnlyPlugins,
288290
required Logger logger,
289291
required FlutterDarwinPlatform platform,
292+
required Analytics analytics,
290293
}) {
291294
if (cocoapodOnlyPlugins.isEmpty) {
292295
return;
@@ -297,6 +300,11 @@ class DarwinDependencyManagement {
297300
'This will become an error in a future version of Flutter. Please contact the plugin '
298301
'maintainers to request Swift Package Manager adoption.',
299302
);
303+
for (final plugin in cocoapodOnlyPlugins) {
304+
analytics.send(
305+
Event.appleUsageEvent(workflow: 'cocoapod-only-plugin-warning', parameter: plugin),
306+
);
307+
}
300308
}
301309

302310
/// Print a message recommending removing CocoaPod integration when all plugins support SwiftPM.

0 commit comments

Comments
 (0)