Impacted Users: iOS and macOS Flutter developers Impact Description: iOS/macOS workflows may not behave as expected due to missing dev dependencies. Workaround: Yes, run in debug mode, such as `flutter build ios --debug --config-only` Risk: low Test Coverage: yes Validation Steps: Run `flutter build ios` on a project with dev dependencies and should see them in the GeneratedPluginRegistrant
This commit is contained in:
parent
fdefa52cef
commit
f3eca332f3
@ -1250,37 +1250,51 @@ Future<void> injectPlugins(
|
||||
bool windowsPlatform = false,
|
||||
DarwinDependencyManagement? darwinDependencyManagement,
|
||||
}) async {
|
||||
List<Plugin> plugins = await findPlugins(project);
|
||||
final List<Plugin> plugins = await findPlugins(project);
|
||||
|
||||
// Filter out dev dependencies for release builds.
|
||||
final List<Plugin> filteredPlugins;
|
||||
if (releaseMode) {
|
||||
plugins = plugins.where((Plugin p) => !p.isDevDependency).toList();
|
||||
filteredPlugins = plugins.where((Plugin p) => !p.isDevDependency).toList();
|
||||
} else {
|
||||
filteredPlugins = plugins;
|
||||
}
|
||||
|
||||
final Map<String, List<Plugin>> pluginsByPlatform = _resolvePluginImplementations(
|
||||
plugins,
|
||||
final Map<String, List<Plugin>> filteredPluginsByPlatform = _resolvePluginImplementations(
|
||||
filteredPlugins,
|
||||
pluginResolutionType: _PluginResolutionType.nativeOrDart,
|
||||
);
|
||||
|
||||
if (androidPlatform) {
|
||||
await _writeAndroidPluginRegistrant(project, pluginsByPlatform[AndroidPlugin.kConfigKey]!);
|
||||
}
|
||||
if (iosPlatform) {
|
||||
await _writeIOSPluginRegistrant(project, pluginsByPlatform[IOSPlugin.kConfigKey]!);
|
||||
await _writeAndroidPluginRegistrant(
|
||||
project,
|
||||
filteredPluginsByPlatform[AndroidPlugin.kConfigKey]!,
|
||||
);
|
||||
}
|
||||
if (linuxPlatform) {
|
||||
await _writeLinuxPluginFiles(project, pluginsByPlatform[LinuxPlugin.kConfigKey]!);
|
||||
}
|
||||
if (macOSPlatform) {
|
||||
await _writeMacOSPluginRegistrant(project, pluginsByPlatform[MacOSPlugin.kConfigKey]!);
|
||||
await _writeLinuxPluginFiles(project, filteredPluginsByPlatform[LinuxPlugin.kConfigKey]!);
|
||||
}
|
||||
if (windowsPlatform) {
|
||||
await writeWindowsPluginFiles(
|
||||
project,
|
||||
pluginsByPlatform[WindowsPlugin.kConfigKey]!,
|
||||
filteredPluginsByPlatform[WindowsPlugin.kConfigKey]!,
|
||||
globals.templateRenderer,
|
||||
);
|
||||
}
|
||||
|
||||
if (iosPlatform || macOSPlatform) {
|
||||
// iOS and macOS doesn't yet support filtering out dev dependencies.
|
||||
// See https://github.com/flutter/flutter/issues/163874.
|
||||
final Map<String, List<Plugin>> pluginsByPlatform = _resolvePluginImplementations(
|
||||
plugins,
|
||||
pluginResolutionType: _PluginResolutionType.nativeOrDart,
|
||||
);
|
||||
if (iosPlatform) {
|
||||
await _writeIOSPluginRegistrant(project, pluginsByPlatform[IOSPlugin.kConfigKey]!);
|
||||
}
|
||||
if (macOSPlatform) {
|
||||
await _writeMacOSPluginRegistrant(project, pluginsByPlatform[MacOSPlugin.kConfigKey]!);
|
||||
}
|
||||
final DarwinDependencyManagement darwinDependencyManagerSetup =
|
||||
darwinDependencyManagement ??
|
||||
DarwinDependencyManagement(
|
||||
|
@ -2649,7 +2649,7 @@ flutter:
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'excludes dev dependencies from iOS plugin registrant',
|
||||
'includes dev dependencies from iOS plugin registrant',
|
||||
() async {
|
||||
createPlugin(
|
||||
name: testPluginName,
|
||||
@ -2682,7 +2682,7 @@ flutter:
|
||||
releaseMode: true,
|
||||
);
|
||||
expect(generatedPluginRegistrantImpl, exists);
|
||||
expect(generatedPluginRegistrantImpl.readAsStringSync(), isNot(contains(devDepImport)));
|
||||
expect(generatedPluginRegistrantImpl.readAsStringSync(), contains(devDepImport));
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
@ -2729,7 +2729,7 @@ flutter:
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'excludes dev dependencies from MacOS plugin registrant',
|
||||
'includes dev dependencies from MacOS plugin registrant',
|
||||
() async {
|
||||
createPlugin(
|
||||
name: testPluginName,
|
||||
@ -2767,7 +2767,7 @@ flutter:
|
||||
expect(generatedPluginRegistrant, exists);
|
||||
expect(
|
||||
generatedPluginRegistrant.readAsStringSync(),
|
||||
isNot(contains(expectedDevDepRegistration)),
|
||||
contains(expectedDevDepRegistration),
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
|
Loading…
x
Reference in New Issue
Block a user