Unverified Commit 57d52228 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Include -isysroot -arch and -miphoneos-version-min when creating dummy module...

Include -isysroot -arch and -miphoneos-version-min when creating dummy module App.framework (#97689)
parent 7868284a
......@@ -246,6 +246,9 @@ dependencies:
final Directory objectiveCBuildDirectory = Directory(path.join(tempDir.path, 'build-objc'));
section('Build iOS Objective-C host app');
final File dummyAppFramework = File(path.join(projectDir.path, '.ios', 'Flutter', 'App.framework', 'App'));
checkFileNotExists(dummyAppFramework.path);
await inDirectory(objectiveCHostApp, () async {
await exec(
'pod',
......@@ -267,6 +270,14 @@ dependencies:
throw TaskResult.failure('Building host app Podfile.lock does not contain expected pods');
}
// Just running "pod install" should create a fake App.framework so CocoaPods recognizes
// it as a framework that needs to be embedded, before Flutter actually creates it.
checkFileExists(dummyAppFramework.path);
final String? version = await minPhoneOSVersion(dummyAppFramework.path);
if (version != '9.0') {
throw TaskResult.failure('Minimum version set to $version, expected 9.0');
}
await exec(
'xcodebuild',
<String>[
......
......@@ -16,6 +16,37 @@ Future<String> fileType(String pathToBinary) {
return eval('file', <String>[pathToBinary]);
}
Future<String?> minPhoneOSVersion(String pathToBinary) async {
final String loadCommands = await eval('otool', <String>[
'-l',
'-arch',
'arm64',
pathToBinary,
]);
if (!loadCommands.contains('LC_VERSION_MIN_IPHONEOS')) {
return null;
}
String? minVersion;
// Load command 7
// cmd LC_VERSION_MIN_IPHONEOS
// cmdsize 16
// version 9.0
// sdk 15.2
// ...
final List<String> lines = LineSplitter.split(loadCommands).toList();
lines.asMap().forEach((int index, String line) {
if (line.contains('LC_VERSION_MIN_IPHONEOS') && lines.length - index - 1 > 3) {
final String versionLine = lines
.skip(index - 1)
.take(4).last;
final RegExp versionRegex = RegExp(r'\s*version\s*(\S*)');
minVersion = versionRegex.firstMatch(versionLine)?.group(1);
}
});
return minVersion;
}
Future<bool> containsBitcode(String pathToBinary) async {
// See: https://stackoverflow.com/questions/32755775/how-to-check-a-static-library-is-built-contain-bitcode
final String loadCommands = await eval('otool', <String>[
......
......@@ -109,7 +109,8 @@ def install_flutter_application_pod(flutter_application_path)
# CocoaPods will not embed the framework on pod install (before any build phases can run) if the dylib does not exist.
# Create a dummy dylib.
FileUtils.mkdir_p(app_framework_dir)
`echo "static const int Moo = 88;" | xcrun clang -x c -dynamiclib -o "#{app_framework_dylib}" -`
sdk_path = `xcrun --sdk iphoneos --show-sdk-path`.strip
`echo "static const int Moo = 88;" | xcrun clang -x c -arch arm64 -dynamiclib -miphoneos-version-min=9.0 -isysroot "#{sdk_path}" -o "#{app_framework_dylib}" -`
end
# Keep pod and script phase paths relative so they can be checked into source control.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment