This reverts commit abdd65fc29.
This commit is contained in:
@@ -113,7 +113,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
|
||||
final String name = 'ios-framework';
|
||||
|
||||
@override
|
||||
final String description = 'Produces .frameworks for a Flutter project '
|
||||
final String description = 'Produces a .framework directory for a Flutter module '
|
||||
'and its plugins for integration into existing, plain Xcode projects.\n'
|
||||
'This can only be run on macOS hosts.';
|
||||
|
||||
@@ -144,6 +144,10 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
|
||||
Future<void> validateCommand() async {
|
||||
await super.validateCommand();
|
||||
_project = FlutterProject.current();
|
||||
if (!_project.isModule) {
|
||||
throwToolExit('Building frameworks for iOS is only supported from a module.');
|
||||
}
|
||||
|
||||
if (!_platform.isMacOS) {
|
||||
throwToolExit('Building frameworks for iOS is only supported on the Mac.');
|
||||
}
|
||||
@@ -174,7 +178,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
|
||||
}
|
||||
|
||||
if (!_project.ios.existsSync()) {
|
||||
throwToolExit('Project does not support iOS');
|
||||
throwToolExit('Module does not support iOS');
|
||||
}
|
||||
|
||||
final Directory outputDirectory = globals.fs.directory(globals.fs.path.absolute(globals.fs.path.normalize(outputArgument)));
|
||||
@@ -229,23 +233,6 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
|
||||
}
|
||||
|
||||
globals.printStatus('Frameworks written to ${outputDirectory.path}.');
|
||||
|
||||
if (!_project.isModule && hasPlugins(_project)) {
|
||||
// Apps do not generate a FlutterPluginRegistrant.framework. Users will need
|
||||
// to copy the GeneratedPluginRegistrant class to their project manually.
|
||||
final File pluginRegistrantHeader = _project.ios.pluginRegistrantHeader;
|
||||
final File pluginRegistrantImplementation =
|
||||
_project.ios.pluginRegistrantImplementation;
|
||||
pluginRegistrantHeader.copySync(
|
||||
outputDirectory.childFile(pluginRegistrantHeader.basename).path);
|
||||
pluginRegistrantImplementation.copySync(outputDirectory
|
||||
.childFile(pluginRegistrantImplementation.basename)
|
||||
.path);
|
||||
globals.printStatus(
|
||||
'\nCopy the ${globals.fs.path.basenameWithoutExtension(pluginRegistrantHeader.path)} class into your project.\n'
|
||||
'See https://flutter.dev/docs/development/add-to-app/ios/add-flutter-screen#create-a-flutterengine for more information.');
|
||||
}
|
||||
|
||||
return FlutterCommandResult.success();
|
||||
}
|
||||
|
||||
@@ -472,7 +459,6 @@ end
|
||||
xcodeBuildConfiguration,
|
||||
'SYMROOT=${iPhoneBuildOutput.path}',
|
||||
'BITCODE_GENERATION_MODE=$bitcodeGenerationMode',
|
||||
'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
|
||||
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
||||
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
||||
];
|
||||
@@ -497,7 +483,6 @@ end
|
||||
'-configuration',
|
||||
xcodeBuildConfiguration,
|
||||
'SYMROOT=${simulatorBuildOutput.path}',
|
||||
'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
|
||||
'ARCHS=x86_64',
|
||||
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
||||
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
||||
|
||||
@@ -897,24 +897,36 @@ Future<void> _writeIOSPluginRegistrant(FlutterProject project, List<Plugin> plug
|
||||
'framework': 'Flutter',
|
||||
'plugins': iosPlugins,
|
||||
};
|
||||
final String registryDirectory = project.ios.pluginRegistrantHost.path;
|
||||
if (project.isModule) {
|
||||
final String registryDirectory = project.ios.pluginRegistrantHost.path;
|
||||
final String registryClassesDirectory = globals.fs.path.join(registryDirectory, 'Classes');
|
||||
_renderTemplateToFile(
|
||||
_pluginRegistrantPodspecTemplate,
|
||||
context,
|
||||
globals.fs.path.join(registryDirectory, 'FlutterPluginRegistrant.podspec'),
|
||||
);
|
||||
_renderTemplateToFile(
|
||||
_objcPluginRegistryHeaderTemplate,
|
||||
context,
|
||||
globals.fs.path.join(registryClassesDirectory, 'GeneratedPluginRegistrant.h'),
|
||||
);
|
||||
_renderTemplateToFile(
|
||||
_objcPluginRegistryImplementationTemplate,
|
||||
context,
|
||||
globals.fs.path.join(registryClassesDirectory, 'GeneratedPluginRegistrant.m'),
|
||||
);
|
||||
} else {
|
||||
_renderTemplateToFile(
|
||||
_objcPluginRegistryHeaderTemplate,
|
||||
context,
|
||||
globals.fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.h'),
|
||||
);
|
||||
_renderTemplateToFile(
|
||||
_objcPluginRegistryImplementationTemplate,
|
||||
context,
|
||||
globals.fs.path.join(registryDirectory, 'GeneratedPluginRegistrant.m'),
|
||||
);
|
||||
}
|
||||
_renderTemplateToFile(
|
||||
_objcPluginRegistryHeaderTemplate,
|
||||
context,
|
||||
project.ios.pluginRegistrantHeader.path,
|
||||
);
|
||||
_renderTemplateToFile(
|
||||
_objcPluginRegistryImplementationTemplate,
|
||||
context,
|
||||
project.ios.pluginRegistrantImplementation.path,
|
||||
);
|
||||
}
|
||||
|
||||
/// The relative path from a project's main CMake file to the plugin symlink
|
||||
|
||||
@@ -665,12 +665,15 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
|
||||
)
|
||||
);
|
||||
if (framework.existsSync()) {
|
||||
final Directory engineDest = ephemeralDirectory
|
||||
.childDirectory('Flutter')
|
||||
.childDirectory('engine');
|
||||
final File podspec = framework.parent.childFile('Flutter.podspec');
|
||||
globals.fsUtils.copyDirectorySync(
|
||||
framework,
|
||||
engineCopyDirectory.childDirectory('Flutter.framework'),
|
||||
engineDest.childDirectory('Flutter.framework'),
|
||||
);
|
||||
podspec.copySync(engineCopyDirectory.childFile('Flutter.podspec').path);
|
||||
podspec.copySync(engineDest.childFile('Flutter.podspec').path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,22 +704,6 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
|
||||
: hostAppRoot.childDirectory(_hostAppProjectName);
|
||||
}
|
||||
|
||||
File get pluginRegistrantHeader {
|
||||
final Directory registryDirectory = isModule ? pluginRegistrantHost.childDirectory('Classes') : pluginRegistrantHost;
|
||||
return registryDirectory.childFile('GeneratedPluginRegistrant.h');
|
||||
}
|
||||
|
||||
File get pluginRegistrantImplementation {
|
||||
final Directory registryDirectory = isModule ? pluginRegistrantHost.childDirectory('Classes') : pluginRegistrantHost;
|
||||
return registryDirectory.childFile('GeneratedPluginRegistrant.m');
|
||||
}
|
||||
|
||||
Directory get engineCopyDirectory {
|
||||
return isModule
|
||||
? ephemeralDirectory.childDirectory('Flutter').childDirectory('engine')
|
||||
: hostAppRoot.childDirectory('Flutter');
|
||||
}
|
||||
|
||||
Future<void> _overwriteFromTemplate(String path, Directory target) async {
|
||||
final Template template = await Template.fromName(
|
||||
path,
|
||||
|
||||
Reference in New Issue
Block a user