From 71d52f27fb12630380e946b733b78bb282011fda Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 8 Apr 2022 16:12:09 -0700 Subject: [PATCH] Test Flutter.xcframework directory ios-arm64_armv7 or ios-arm64 (#101592) --- .../build_ios_framework_module_test.dart | 40 ++++++++++++++++--- packages/flutter_tools/bin/podhelper.rb | 2 +- packages/flutter_tools/lib/src/artifacts.dart | 2 +- .../test/general.shard/artifacts_test.dart | 30 ++++++++++++-- 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart b/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart index 3deac256668..d4ffdb24bdd 100644 --- a/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart +++ b/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart @@ -111,14 +111,28 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals final String outputPath = path.join(projectDir.path, outputDirectoryName); - checkFileExists(path.join( + // TODO(jmagman): Remove ios-arm64_armv7 checks when armv7 engine artifacts are removed. + final String arm64FlutterFramework = path.join( + outputPath, + 'Debug', + 'Flutter.xcframework', + 'ios-arm64', + 'Flutter.framework', + ); + + final String armv7FlutterFramework = path.join( outputPath, 'Debug', 'Flutter.xcframework', 'ios-arm64_armv7', 'Flutter.framework', - 'Flutter', - )); + ); + + final bool arm64FlutterBinaryExists = exists(File(path.join(arm64FlutterFramework, 'Flutter'))); + final bool armv7FlutterBinaryExists = exists(File(path.join(armv7FlutterFramework, 'Flutter'))); + if (!arm64FlutterBinaryExists && !armv7FlutterBinaryExists) { + throw TaskResult.failure('Expected debug Flutter engine artifact binary to exist'); + } final String debugAppFrameworkPath = path.join( outputPath, @@ -226,7 +240,17 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals section("Check all modes' engine dylib"); for (final String mode in ['Debug', 'Profile', 'Release']) { - final String engineFrameworkPath = path.join( + // TODO(jmagman): Remove ios-arm64_armv7 checks when armv7 engine artifacts are removed. + final String arm64EngineBinary = path.join( + outputPath, + mode, + 'Flutter.xcframework', + 'ios-arm64', + 'Flutter.framework', + 'Flutter', + ); + + final String arm64Armv7EngineBinary = path.join( outputPath, mode, 'Flutter.xcframework', @@ -235,7 +259,13 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals 'Flutter', ); - await _checkBitcode(engineFrameworkPath, mode); + if (exists(File(arm64EngineBinary))) { + await _checkBitcode(arm64EngineBinary, mode); + } else if (exists(File(arm64Armv7EngineBinary))) { + await _checkBitcode(arm64Armv7EngineBinary, mode); + } else { + throw TaskResult.failure('Expected Flutter $mode engine artifact binary to exist'); + } checkFileExists(path.join( outputPath, diff --git a/packages/flutter_tools/bin/podhelper.rb b/packages/flutter_tools/bin/podhelper.rb index 108eb23a205..3c41e887a43 100644 --- a/packages/flutter_tools/bin/podhelper.rb +++ b/packages/flutter_tools/bin/podhelper.rb @@ -63,7 +63,7 @@ def flutter_additional_ios_build_settings(target) continue if xcframework_file.start_with?(".") # Hidden file, possibly on external disk. if xcframework_file.end_with?("-simulator") # ios-arm64_x86_64-simulator build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)" - elsif xcframework_file.start_with?("ios-") # ios-armv7_arm64 + elsif xcframework_file.start_with?("ios-") # ios-arm64 build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)" else # Info.plist or another platform. diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 084ae3300fa..2aac9686e82 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -727,7 +727,7 @@ String _getIosEngineArtifactPath(String engineDirectory, if (!platformDirectory.basename.startsWith('ios-')) { continue; } - // ios-x86_64-simulator, ios-arm64_x86_64-simulator, ios-armv7_arm64 (Xcode 11), or ios-arm64_armv7 (Xcode 12). + // ios-x86_64-simulator, ios-arm64_x86_64-simulator, or ios-arm64. final bool simulatorDirectory = platformDirectory.basename.endsWith('-simulator'); if ((environmentType == EnvironmentType.simulator && simulatorDirectory) || (environmentType == EnvironmentType.physical && !simulatorDirectory)) { diff --git a/packages/flutter_tools/test/general.shard/artifacts_test.dart b/packages/flutter_tools/test/general.shard/artifacts_test.dart index ce07a12450e..d906511a159 100644 --- a/packages/flutter_tools/test/general.shard/artifacts_test.dart +++ b/packages/flutter_tools/test/general.shard/artifacts_test.dart @@ -87,6 +87,13 @@ void main() { .childDirectory('ios-arm64_x86_64-simulator') .childDirectory('Flutter.framework') .createSync(recursive: true); + fileSystem + .directory(xcframeworkPath) + .childDirectory('ios-arm64') + .childDirectory('Flutter.framework') + .createSync(recursive: true); + + // TODO(jmagman): Remove ios-arm64_armv7 checks when armv7 engine artifacts are removed. fileSystem .directory(xcframeworkPath) .childDirectory('ios-arm64_armv7') @@ -100,10 +107,27 @@ void main() { fileSystem.path .join(xcframeworkPath, 'ios-arm64_x86_64-simulator', 'Flutter.framework'), ); + final String actualReleaseFrameworkArtifact = artifacts.getArtifactPath( + Artifact.flutterFramework, + platform: TargetPlatform.ios, + mode: BuildMode.release, + environmentType: EnvironmentType.physical, + ); + final String expectedArm64ReleaseFrameworkArtifact = fileSystem.path.join( + xcframeworkPath, + 'ios-arm64', + 'Flutter.framework', + ); + final String expectedArmv7ReleaseFrameworkArtifact = fileSystem.path.join( + xcframeworkPath, + 'ios-arm64_armv7', + 'Flutter.framework', + ); + + // TODO(jmagman): Replace with expect(actualReleaseFrameworkArtifact, expectedArm64ReleaseFrameworkArtifact) when armv7 engine artifacts are removed. expect( - artifacts.getArtifactPath(Artifact.flutterFramework, - platform: TargetPlatform.ios, mode: BuildMode.release, environmentType: EnvironmentType.physical), - fileSystem.path.join(xcframeworkPath, 'ios-arm64_armv7', 'Flutter.framework'), + actualReleaseFrameworkArtifact, + anyOf(expectedArm64ReleaseFrameworkArtifact, expectedArmv7ReleaseFrameworkArtifact), ); expect( artifacts.getArtifactPath(Artifact.flutterXcframework, platform: TargetPlatform.ios, mode: BuildMode.release),