Skip to content

Commit 7141eb3

Browse files
authored
[tool] Add a telemetry event to track SwiftPM migration (flutter#166773)
Flutter is migrating from CocoaPods to Swift Package Manager to manage native dependencies on iOS and macOS. We'd like to answer the following questions: 1. Can we remove CocoaPods support from Flutter's tooling? 2. Can we tell plugin authors that they can remove CocoaPods integration from their plugins? This makes the Flutter tool send an event when it injects plugins into an iOS or macOS project. This will happen whenever a user does commands like `flutter build ios`, `flutter build macos`, and more. Part of flutter#147602 Depends on: dart-lang/tools#2062 ## 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]. <!-- 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 a46bf19 commit 7141eb3

File tree

3 files changed

+310
-50
lines changed

3 files changed

+310
-50
lines changed

packages/flutter_tools/lib/src/flutter_plugins.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,9 @@ Future<void> injectPlugins(
13271327
templateRenderer: globals.templateRenderer,
13281328
),
13291329
fileSystem: globals.fs,
1330+
featureFlags: featureFlags,
13301331
logger: globals.logger,
1332+
analytics: globals.analytics,
13311333
);
13321334
if (iosPlatform) {
13331335
await darwinDependencyManagerSetup.setUp(platform: SupportedPlatform.ios);

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:unified_analytics/unified_analytics.dart';
6+
57
import '../base/common.dart';
68
import '../base/file_system.dart';
79
import '../base/logger.dart';
10+
import '../features.dart';
811
import '../plugins.dart';
912
import '../project.dart';
1013
import 'cocoapods.dart';
@@ -21,20 +24,26 @@ class DarwinDependencyManagement {
2124
required CocoaPods cocoapods,
2225
required SwiftPackageManager swiftPackageManager,
2326
required FileSystem fileSystem,
27+
required FeatureFlags featureFlags,
2428
required Logger logger,
29+
required Analytics analytics,
2530
}) : _project = project,
2631
_plugins = plugins,
2732
_cocoapods = cocoapods,
2833
_swiftPackageManager = swiftPackageManager,
2934
_fileSystem = fileSystem,
30-
_logger = logger;
35+
_featureFlags = featureFlags,
36+
_logger = logger,
37+
_analytics = analytics;
3138

3239
final FlutterProject _project;
3340
final List<Plugin> _plugins;
3441
final CocoaPods _cocoapods;
3542
final SwiftPackageManager _swiftPackageManager;
3643
final FileSystem _fileSystem;
44+
final FeatureFlags _featureFlags;
3745
final Logger _logger;
46+
final Analytics _analytics;
3847

3948
/// Generates/updates required files and project settings for Darwin
4049
/// Dependency Managers (CocoaPods and Swift Package Manager). Projects may
@@ -87,6 +96,7 @@ class DarwinDependencyManagement {
8796
// whether to run.
8897
useCocoapods = _plugins.isNotEmpty;
8998
}
99+
90100
if (useCocoapods) {
91101
await _cocoapods.setupPodfile(xcodeProject);
92102
}
@@ -95,6 +105,21 @@ class DarwinDependencyManagement {
95105
else if (xcodeProject.podfile.existsSync() && xcodeProject.podfileLock.existsSync()) {
96106
_cocoapods.addPodsDependencyToFlutterXcconfig(xcodeProject);
97107
}
108+
109+
final Event event = Event.flutterInjectDarwinPlugins(
110+
platform: platform.name,
111+
isModule: _project.isModule,
112+
swiftPackageManagerUsable: xcodeProject.usesSwiftPackageManager,
113+
swiftPackageManagerFeatureEnabled: _featureFlags.isSwiftPackageManagerEnabled,
114+
projectDisabledSwiftPackageManager: _project.manifest.disabledSwiftPackageManager,
115+
projectHasSwiftPackageManagerIntegration:
116+
xcodeProject.flutterPluginSwiftPackageInProjectSettings,
117+
pluginCount: totalCount,
118+
swiftPackageCount: swiftPackageCount,
119+
podCount: podCount,
120+
);
121+
122+
_analytics.send(event);
98123
}
99124

100125
/// Returns count of total number of plugins, number of Swift Package Manager

0 commit comments

Comments
 (0)