From 66d77ca04894d7a7eec560fa4399aad40f946d49 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 16 Apr 2020 15:18:33 -0700 Subject: [PATCH] Support armv7s architecture (#54989) --- .../flutter_tools/lib/src/build_info.dart | 1 + .../flutter_tools/lib/src/macos/xcode.dart | 9 +++- .../test/general.shard/macos/xcode_test.dart | 44 +++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/build_info.dart b/packages/flutter_tools/lib/src/build_info.dart index 3c62e06229..324c77268e 100644 --- a/packages/flutter_tools/lib/src/build_info.dart +++ b/packages/flutter_tools/lib/src/build_info.dart @@ -400,6 +400,7 @@ DarwinArch getIOSArchForName(String arch) { switch (arch) { case 'armv7': case 'armv7f': // iPhone 4S. + case 'armv7s': // iPad 4. return DarwinArch.armv7; case 'arm64': case 'arm64e': // iPhone XS/XS Max/XR and higher. arm64 runs on arm64e devices. diff --git a/packages/flutter_tools/lib/src/macos/xcode.dart b/packages/flutter_tools/lib/src/macos/xcode.dart index f259e0a74f..168396ad88 100644 --- a/packages/flutter_tools/lib/src/macos/xcode.dart +++ b/packages/flutter_tools/lib/src/macos/xcode.dart @@ -435,8 +435,13 @@ class XCDevice { } on Exception { // Fallback to default iOS architecture. Future-proof against a // theoretical version of Xcode that changes this string to something - // slightly different like "ARM64". - cpuArchitecture ??= defaultIOSArchs.first; + // slightly different like "ARM64", or armv7 variations like + // armv7s and armv7f. + if (architecture.startsWith('armv7')) { + cpuArchitecture = DarwinArch.armv7; + } else { + cpuArchitecture = defaultIOSArchs.first; + } _logger.printError( 'Unknown architecture $architecture, defaulting to ' '${getNameForDarwinArch(cpuArchitecture)}', diff --git a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart index 3074db62fe..2dedeced63 100644 --- a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart @@ -443,6 +443,50 @@ void main() { }, overrides: { Platform: () => macPlatform, }); + + testUsingContext('handles unknown architectures', () async { + when(mockXcode.isInstalledAndMeetsVersionCheck).thenReturn(true); + + when(processManager.runSync(['xcrun', '--find', 'xcdevice'])) + .thenReturn(ProcessResult(1, 0, '/path/to/xcdevice', '')); + + const String devicesOutput = ''' +[ + { + "simulator" : false, + "operatingSystemVersion" : "13.3 (17C54)", + "interface" : "usb", + "available" : true, + "platform" : "com.apple.platform.iphoneos", + "modelCode" : "iPhone8,1", + "identifier" : "d83d5bc53967baa0ee18626ba87b6254b2ab5418", + "architecture" : "armv7x", + "modelName" : "iPad 3 BOGUS", + "name" : "iPad" + }, + { + "simulator" : false, + "operatingSystemVersion" : "13.3 (17C54)", + "interface" : "usb", + "available" : true, + "platform" : "com.apple.platform.iphoneos", + "modelCode" : "iPhone8,1", + "identifier" : "d83d5bc53967baa0ee18626ba87b6254b2ab5418", + "architecture" : "BOGUS", + "modelName" : "Future iPad", + "name" : "iPad" + } +] +'''; + + when(processManager.run(['xcrun', 'xcdevice', 'list', '--timeout', '2'])) + .thenAnswer((_) => Future.value(ProcessResult(1, 0, devicesOutput, ''))); + final List devices = await xcdevice.getAvailableTetheredIOSDevices(); + expect(devices[0].cpuArchitecture, DarwinArch.armv7); + expect(devices[1].cpuArchitecture, DarwinArch.arm64); + }, overrides: { + Platform: () => macPlatform, + }); }); group('diagnostics', () {