[flutter_tools] build ios-frameworks: option to exclude plugin frameworks from the build (#129739)
A lot of details are written in the feature request: https://github.com/flutter/flutter/issues/114692. tl;dr: Options B & C from the add2app iOS guide have a limitation (build error) in case the Flutter plugin and native iOS app have a shared dependency. We can use a workaround to avoid the issue, but in this case we don't need to build frameworks for plugins. Closes https://github.com/flutter/flutter/issues/114692 Part of https://github.com/flutter/flutter/issues/130220
This commit is contained in:
@@ -68,6 +68,11 @@ abstract class BuildFrameworkCommand extends BuildSubCommand {
|
||||
..addFlag('cocoapods',
|
||||
help: 'Produce a Flutter.podspec instead of an engine Flutter.xcframework (recommended if host app uses CocoaPods).',
|
||||
)
|
||||
..addFlag('plugins',
|
||||
defaultsTo: true,
|
||||
help: 'Whether to produce frameworks for the plugins. '
|
||||
'This is intended for cases where plugins are already being built separately.',
|
||||
)
|
||||
..addFlag('static',
|
||||
help: 'Build plugins as static frameworks. Link on, but do not embed these frameworks in the existing Xcode project.',
|
||||
)
|
||||
@@ -135,6 +140,10 @@ abstract class BuildFrameworkCommand extends BuildSubCommand {
|
||||
if ((await getBuildInfos()).isEmpty) {
|
||||
throwToolExit('At least one of "--debug" or "--profile", or "--release" is required.');
|
||||
}
|
||||
|
||||
if (!boolArg('plugins') && boolArg('static')) {
|
||||
throwToolExit('--static cannot be used with the --no-plugins flag');
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> produceXCFramework(
|
||||
@@ -264,7 +273,7 @@ class BuildIOSFrameworkCommand extends BuildFrameworkCommand {
|
||||
|
||||
// Build and copy plugins.
|
||||
await processPodsIfNeeded(project.ios, getIosBuildDirectory(), buildInfo.mode);
|
||||
if (hasPlugins(project)) {
|
||||
if (boolArg('plugins') && hasPlugins(project)) {
|
||||
await _producePlugins(buildInfo.mode, xcodeBuildConfiguration, iPhoneBuildOutput, simulatorBuildOutput, modeDirectory);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class BuildMacOSFrameworkCommand extends BuildFrameworkCommand {
|
||||
// Build and copy plugins.
|
||||
final Directory buildOutput = modeDirectory.childDirectory('macos');
|
||||
await processPodsIfNeeded(project.macos, getMacOSBuildDirectory(), buildInfo.mode);
|
||||
if (hasPlugins(project)) {
|
||||
if (boolArg('plugins') && hasPlugins(project)) {
|
||||
await _producePlugins(xcodeBuildConfiguration, buildOutput, modeDirectory);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user