Create static plugin frameworks build ios-framework --static (#104576)
This commit is contained in:
parent
78a0d3d4e2
commit
f3e567c901
@ -194,6 +194,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
'App',
|
'App',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await _checkDylib(appFrameworkPath);
|
||||||
await _checkBitcode(appFrameworkPath, mode);
|
await _checkBitcode(appFrameworkPath, mode);
|
||||||
|
|
||||||
final String aotSymbols = await _dylibSymbols(appFrameworkPath);
|
final String aotSymbols = await _dylibSymbols(appFrameworkPath);
|
||||||
@ -292,6 +293,8 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
'connectivity.framework',
|
'connectivity.framework',
|
||||||
'connectivity',
|
'connectivity',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await _checkDylib(pluginFrameworkPath);
|
||||||
await _checkBitcode(pluginFrameworkPath, mode);
|
await _checkBitcode(pluginFrameworkPath, mode);
|
||||||
if (!await _linksOnFlutter(pluginFrameworkPath)) {
|
if (!await _linksOnFlutter(pluginFrameworkPath)) {
|
||||||
throw TaskResult.failure('$pluginFrameworkPath does not link on Flutter');
|
throw TaskResult.failure('$pluginFrameworkPath does not link on Flutter');
|
||||||
@ -375,6 +378,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
'FlutterPluginRegistrant.framework',
|
'FlutterPluginRegistrant.framework',
|
||||||
'FlutterPluginRegistrant',
|
'FlutterPluginRegistrant',
|
||||||
);
|
);
|
||||||
|
await _checkStatic(registrantFrameworkPath);
|
||||||
await _checkBitcode(registrantFrameworkPath, mode);
|
await _checkBitcode(registrantFrameworkPath, mode);
|
||||||
|
|
||||||
checkFileExists(path.join(
|
checkFileExists(path.join(
|
||||||
@ -399,7 +403,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This builds all build modes' frameworks by default
|
// This builds all build modes' frameworks by default
|
||||||
section('Build podspec');
|
section('Build podspec and static plugins');
|
||||||
|
|
||||||
const String cocoapodsOutputDirectoryName = 'flutter-frameworks-cocoapods';
|
const String cocoapodsOutputDirectoryName = 'flutter-frameworks-cocoapods';
|
||||||
|
|
||||||
@ -411,6 +415,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
'--cocoapods',
|
'--cocoapods',
|
||||||
'--force', // Allow podspec creation on master.
|
'--force', // Allow podspec creation on master.
|
||||||
'--output=$cocoapodsOutputDirectoryName',
|
'--output=$cocoapodsOutputDirectoryName',
|
||||||
|
'--static',
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -422,11 +427,13 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
mode,
|
mode,
|
||||||
'Flutter.podspec',
|
'Flutter.podspec',
|
||||||
));
|
));
|
||||||
|
await _checkDylib(path.join(
|
||||||
checkDirectoryExists(path.join(
|
|
||||||
cocoapodsOutputPath,
|
cocoapodsOutputPath,
|
||||||
mode,
|
mode,
|
||||||
'App.xcframework',
|
'App.xcframework',
|
||||||
|
'ios-arm64',
|
||||||
|
'App.framework',
|
||||||
|
'App',
|
||||||
));
|
));
|
||||||
|
|
||||||
if (Directory(path.join(
|
if (Directory(path.join(
|
||||||
@ -439,16 +446,22 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
'Unexpected FlutterPluginRegistrant.xcframework.');
|
'Unexpected FlutterPluginRegistrant.xcframework.');
|
||||||
}
|
}
|
||||||
|
|
||||||
checkDirectoryExists(path.join(
|
await _checkStatic(path.join(
|
||||||
cocoapodsOutputPath,
|
cocoapodsOutputPath,
|
||||||
mode,
|
mode,
|
||||||
'package_info.xcframework',
|
'package_info.xcframework',
|
||||||
|
'ios-arm64',
|
||||||
|
'package_info.framework',
|
||||||
|
'package_info',
|
||||||
));
|
));
|
||||||
|
|
||||||
checkDirectoryExists(path.join(
|
await _checkStatic(path.join(
|
||||||
cocoapodsOutputPath,
|
cocoapodsOutputPath,
|
||||||
mode,
|
mode,
|
||||||
'connectivity.xcframework',
|
'connectivity.xcframework',
|
||||||
|
'ios-arm64',
|
||||||
|
'connectivity.framework',
|
||||||
|
'connectivity',
|
||||||
));
|
));
|
||||||
|
|
||||||
checkDirectoryExists(path.join(
|
checkDirectoryExists(path.join(
|
||||||
@ -475,6 +488,20 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _checkDylib(String pathToLibrary) async {
|
||||||
|
final String binaryFileType = await fileType(pathToLibrary);
|
||||||
|
if (!binaryFileType.contains('dynamically linked')) {
|
||||||
|
throw TaskResult.failure('$pathToLibrary is not a dylib, found: $binaryFileType');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _checkStatic(String pathToLibrary) async {
|
||||||
|
final String binaryFileType = await fileType(pathToLibrary);
|
||||||
|
if (!binaryFileType.contains('current ar archive random library')) {
|
||||||
|
throw TaskResult.failure('$pathToLibrary is not a static library, found: $binaryFileType');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _checkBitcode(String frameworkPath, String mode) async {
|
Future<void> _checkBitcode(String frameworkPath, String mode) async {
|
||||||
checkFileExists(frameworkPath);
|
checkFileExists(frameworkPath);
|
||||||
|
|
||||||
|
@ -80,6 +80,9 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
|
|||||||
..addFlag('cocoapods',
|
..addFlag('cocoapods',
|
||||||
help: 'Produce a Flutter.podspec instead of an engine Flutter.xcframework (recommended if host app uses CocoaPods).',
|
help: 'Produce a Flutter.podspec instead of an engine Flutter.xcframework (recommended if host app uses CocoaPods).',
|
||||||
)
|
)
|
||||||
|
..addFlag('static',
|
||||||
|
help: 'Build plugins as static frameworks. Link on, but do not embed these frameworks in the existing Xcode project.',
|
||||||
|
)
|
||||||
..addOption('output',
|
..addOption('output',
|
||||||
abbr: 'o',
|
abbr: 'o',
|
||||||
valueHelp: 'path/to/directory/',
|
valueHelp: 'path/to/directory/',
|
||||||
@ -428,6 +431,8 @@ end
|
|||||||
'BITCODE_GENERATION_MODE=$bitcodeGenerationMode',
|
'BITCODE_GENERATION_MODE=$bitcodeGenerationMode',
|
||||||
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
||||||
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
||||||
|
if (boolArg('static') ?? false)
|
||||||
|
'MACH_O_TYPE=staticlib',
|
||||||
];
|
];
|
||||||
|
|
||||||
RunResult buildPluginsResult = await globals.processUtils.run(
|
RunResult buildPluginsResult = await globals.processUtils.run(
|
||||||
@ -453,6 +458,8 @@ end
|
|||||||
'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
|
'ENABLE_BITCODE=YES', // Support host apps with bitcode enabled.
|
||||||
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
'ONLY_ACTIVE_ARCH=NO', // No device targeted, so build all valid architectures.
|
||||||
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
|
||||||
|
if (boolArg('static') ?? false)
|
||||||
|
'MACH_O_TYPE=staticlib',
|
||||||
];
|
];
|
||||||
|
|
||||||
buildPluginsResult = await globals.processUtils.run(
|
buildPluginsResult = await globals.processUtils.run(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user