From fdd75a123ff083f48859af3c37a69bf2802ba9cf Mon Sep 17 00:00:00 2001 From: John Knox Date: Fri, 21 Jun 2019 08:57:03 -0700 Subject: [PATCH] Fix missing simulator bug Summary: Apple has changed the xcrun api in some cases, it seems. Adding support for true instead of YES... Reviewed By: danielbuechele Differential Revision: D15940810 fbshipit-source-id: 94ba2733527e005b989fb5a62ffbab2f7a0243b9 --- src/dispatcher/iOSDevice.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/dispatcher/iOSDevice.js b/src/dispatcher/iOSDevice.js index 2f1222128..99565bcc4 100644 --- a/src/dispatcher/iOSDevice.js +++ b/src/dispatcher/iOSDevice.js @@ -21,13 +21,24 @@ import {registerDeviceCallbackOnPlugins} from '../utils/onRegisterDevice.js'; type iOSSimulatorDevice = {| state: 'Booted' | 'Shutdown' | 'Shutting Down', availability?: string, - isAvailable?: 'YES' | 'NO', + isAvailable?: 'YES' | 'NO' | true | false, name: string, udid: string, |}; type IOSDeviceParams = {udid: string, type: DeviceType, name: string}; +function isAvailable(simulator: iOSSimulatorDevice): boolean { + // For some users "availability" is set, for others it's "isAvailable" + // It's not clear which key is set, so we are checking both. + // We've also seen isAvailable return "YES" and true, depending on version. + return ( + simulator.availability === '(available)' || + simulator.isAvailable === 'YES' || + simulator.isAvailable === true + ); +} + const portforwardingClient = isProduction() ? path.resolve( __dirname, @@ -119,12 +130,7 @@ function getActiveSimulators(): Promise> { return simulators .filter( - simulator => - simulator.state === 'Booted' && - // For some users "availability" is set, for others it's "isAvailable" - // It's not clear which key is set, so we are checking both. - (simulator.availability === '(available)' || - simulator.isAvailable === 'YES'), + simulator => simulator.state === 'Booted' && isAvailable(simulator), ) .map(simulator => { return {