mirror of
https://github.com/status-im/react-native.git
synced 2025-01-15 03:56:03 +00:00
2ad34075f1
Summary: Since Xcode 9 you can run multiple simultaneously. And since I believe React Native advocates using the latest version of Xcode, we can safely remove this constraint. Updated the unit tests. Furthermore it can be found in the [Xcode release notes](https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/WhatsNewXcode/xcode_9/xcode_9.html#//apple_ref/doc/uid/TP40004626-CH8-SW12) that multiple simulators are now supported. This can be tested with the CLI by running `react-native run-ios` twice, but with a different `--simulator` flag, e.g.; react-native run-ios --simulator "iPhone SE" react-native run-ios --simulator "iPhone X" [IOS] [ENHANCEMENT] [local-cli/runIOS/findMatchingSimulator.js] - Allow running multiple simulators Closes https://github.com/facebook/react-native/pull/17284 Differential Revision: D7102790 Pulled By: hramos fbshipit-source-id: 750e7039201e28a1feda2bec1e78144fd9deff98
72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
'use strict';
|
|
|
|
/**
|
|
* Takes in a parsed simulator list and a desired name, and returns an object with the matching simulator.
|
|
*
|
|
* If the simulatorName argument is null, we'll go into default mode and return the currently booted simulator, or if
|
|
* none is booted, it will be the first in the list.
|
|
*
|
|
* @param Object simulators a parsed list from `xcrun simctl list --json devices` command
|
|
* @param String|null simulatorName the string with the name of desired simulator. If null, it will use the currently
|
|
* booted simulator, or if none are booted, the first in the list.
|
|
* @returns {Object} {udid, name, version}
|
|
*/
|
|
function findMatchingSimulator(simulators, simulatorName) {
|
|
if (!simulators.devices) {
|
|
return null;
|
|
}
|
|
const devices = simulators.devices;
|
|
var match;
|
|
for (let version in devices) {
|
|
// Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc)
|
|
if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
|
|
continue;
|
|
}
|
|
for (let i in devices[version]) {
|
|
let simulator = devices[version][i];
|
|
// Skipping non-available simulator
|
|
if (simulator.availability !== '(available)') {
|
|
continue;
|
|
}
|
|
let booted = simulator.state === 'Booted';
|
|
if (booted && simulatorName === null) {
|
|
return {
|
|
udid: simulator.udid,
|
|
name: simulator.name,
|
|
booted,
|
|
version
|
|
};
|
|
}
|
|
if (simulator.name === simulatorName && !match) {
|
|
match = {
|
|
udid: simulator.udid,
|
|
name: simulator.name,
|
|
booted,
|
|
version
|
|
};
|
|
}
|
|
// Keeps track of the first available simulator for use if we can't find one above.
|
|
if (simulatorName === null && !match) {
|
|
match = {
|
|
udid: simulator.udid,
|
|
name: simulator.name,
|
|
booted,
|
|
version
|
|
};
|
|
}
|
|
}
|
|
}
|
|
if (match) {
|
|
return match;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
module.exports = findMatchingSimulator;
|