From a4530b7c12e89852385ab1323921e068c437c1b5 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Tue, 30 Aug 2022 11:51:20 -0700 Subject: [PATCH] Make module tests pass on Xcode 14 (#110556) --- .../build_ios_framework_module_test.dart | 74 +++++++------------ dev/devicelab/bin/tasks/module_test_ios.dart | 2 - dev/devicelab/lib/framework/ios.dart | 7 -- 3 files changed, 26 insertions(+), 57 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 f2185c1bca8a..c25318efede5 100644 --- a/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart +++ b/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart @@ -101,28 +101,14 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals final String outputPath = path.join(projectDir.path, outputDirectoryName); - // TODO(jmagman): Remove ios-arm64_armv7 checks when armv7 engine artifacts are removed. - final String arm64FlutterFramework = path.join( + checkFileExists(path.join( outputPath, 'Debug', 'Flutter.xcframework', 'ios-arm64', 'Flutter.framework', - ); - - final String armv7FlutterFramework = path.join( - outputPath, - 'Debug', - 'Flutter.xcframework', - 'ios-arm64_armv7', - 'Flutter.framework', - ); - - 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'); - } + 'Flutter', + )); final String debugAppFrameworkPath = path.join( outputPath, @@ -225,8 +211,7 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals section("Check all modes' engine dylib"); for (final String mode in ['Debug', 'Profile', 'Release']) { - // TODO(jmagman): Remove ios-arm64_armv7 checks when armv7 engine artifacts are removed. - final String arm64EngineBinary = path.join( + final String engineBinary = path.join( outputPath, mode, 'Flutter.xcframework', @@ -234,23 +219,7 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals 'Flutter.framework', 'Flutter', ); - - final String arm64Armv7EngineBinary = path.join( - outputPath, - mode, - 'Flutter.xcframework', - 'ios-arm64_armv7', - 'Flutter.framework', - 'Flutter', - ); - - 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'); - } + await _checkBitcode(engineBinary, mode); checkFileExists(path.join( outputPath, @@ -285,12 +254,21 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals ); await _checkDylib(pluginFrameworkPath); - await _checkBitcode(pluginFrameworkPath, mode); if (!await _linksOnFlutter(pluginFrameworkPath)) { throw TaskResult.failure('$pluginFrameworkPath does not link on Flutter'); } + // TODO(jmagman): Remove ios-arm64_armv7 checks when CI is updated to Xcode 14. final String transitiveDependencyFrameworkPath = path.join( + outputPath, + mode, + 'Reachability.xcframework', + 'ios-arm64', + 'Reachability.framework', + 'Reachability', + ); + + final String armv7TransitiveDependencyFrameworkPath = path.join( outputPath, mode, 'Reachability.xcframework', @@ -298,8 +276,17 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals 'Reachability.framework', 'Reachability', ); - if (await _linksOnFlutter(transitiveDependencyFrameworkPath)) { - throw TaskResult.failure('Transitive dependency $transitiveDependencyFrameworkPath unexpectedly links on Flutter'); + + final bool transitiveDependencyExists = exists(File(transitiveDependencyFrameworkPath)); + final bool armv7TransitiveDependencyExists = exists(File(armv7TransitiveDependencyFrameworkPath)); + if (!transitiveDependencyExists && !armv7TransitiveDependencyExists) { + throw TaskResult.failure('Expected debug Flutter engine artifact binary to exist'); + } + + if ((transitiveDependencyExists && await _linksOnFlutter(transitiveDependencyFrameworkPath)) || + (armv7TransitiveDependencyExists && await _linksOnFlutter(armv7TransitiveDependencyFrameworkPath))) { + throw TaskResult.failure( + 'Transitive dependency $transitiveDependencyFrameworkPath unexpectedly links on Flutter'); } checkFileExists(path.join( @@ -346,14 +333,6 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals checkFileExists(simulatorFrameworkHeaderPath); } - checkDirectoryExists(path.join( - outputPath, - 'Release', - 'connectivity.xcframework', - 'ios-arm64', - 'BCSymbolMaps', - )); - section('Check all modes have generated plugin registrant'); for (final String mode in ['Debug', 'Profile', 'Release']) { @@ -369,7 +348,6 @@ Future _testBuildIosFramework(Directory projectDir, { bool isModule = fals 'FlutterPluginRegistrant', ); await _checkStatic(registrantFrameworkPath); - await _checkBitcode(registrantFrameworkPath, mode); checkFileExists(path.join( outputPath, diff --git a/dev/devicelab/bin/tasks/module_test_ios.dart b/dev/devicelab/bin/tasks/module_test_ios.dart index 47b17302fe0d..dc230fd01c8c 100644 --- a/dev/devicelab/bin/tasks/module_test_ios.dart +++ b/dev/devicelab/bin/tasks/module_test_ios.dart @@ -421,7 +421,6 @@ end if ((await fileType(builtFlutterBinary)).contains('armv7')) { throw TaskResult.failure('Unexpected armv7 architecture slice in $builtFlutterBinary'); } - await checkContainsBitcode(builtFlutterBinary); final String builtAppBinary = path.join( archivedAppPath, @@ -433,7 +432,6 @@ end if ((await fileType(builtAppBinary)).contains('armv7')) { throw TaskResult.failure('Unexpected armv7 architecture slice in $builtAppBinary'); } - await checkContainsBitcode(builtAppBinary); // The host app example builds plugins statically, url_launcher_ios.framework // should not exist. diff --git a/dev/devicelab/lib/framework/ios.dart b/dev/devicelab/lib/framework/ios.dart index 275781247a69..2a384edbe25f 100644 --- a/dev/devicelab/lib/framework/ios.dart +++ b/dev/devicelab/lib/framework/ios.dart @@ -8,7 +8,6 @@ import 'dart:io'; import 'package:path/path.dart' as path; import 'host_agent.dart'; -import 'task_result.dart'; import 'utils.dart'; typedef SimulatorFunction = Future Function(String deviceId); @@ -85,12 +84,6 @@ Future containsBitcode(String pathToBinary) async { return !emptyBitcodeMarkerFound; } -Future checkContainsBitcode(String pathToBinary) async { - if (!await containsBitcode(pathToBinary)) { - throw TaskResult.failure('Expected bitcode in $pathToBinary'); - } -} - /// Creates and boots a new simulator, passes the new simulator's identifier to /// `testFunction`. ///