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
This commit is contained in:
John Knox
2019-06-21 08:57:03 -07:00
committed by Facebook Github Bot
parent c4acfa6507
commit fdd75a123f

View File

@@ -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<Array<IOSDeviceParams>> {
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 {