Repository navigation
--simulator with name not working as expected after updating to 0.70.1 #1707
Copy link
Copy link
Closed
Labels
Description
Activity
This looks like an issue related to a change in
findMatchingSimulator.tsin this commit: f096553In the loop where it searches for a matching simulator the following was added:
if (!!lastBootedAt && !match) { match = simulatorDescriptor; }This causes the first item in the list to always be found first, thus essentially exiting the loop.
Reacted by Christopher Hockley and Alex FoxReacted by Juan Pablo Bedoya MartínezThe function should be more like:
function findMatchingSimulator(simulators, findOptions) { if (!simulators.devices) { return null } const devices = simulators.devices let simulatorVersion let simulatorName = null if (findOptions && findOptions.simulator) { const parsedSimulatorName = findOptions.simulator.match(/(.*)? (?:\((\d+\.\d+)?\))$/) if (parsedSimulatorName && parsedSimulatorName[2] !== undefined) { simulatorVersion = parsedSimulatorName[2] simulatorName = parsedSimulatorName[1] } else { simulatorName = findOptions.simulator } } let match let defaultMatch // ADDED for (const versionDescriptor in devices) { const device = devices[versionDescriptor] let version = versionDescriptor if (/^com\.apple\.CoreSimulator\.SimRuntime\./g.test(version)) { // Transform "com.apple.CoreSimulator.SimRuntime.iOS-12-2" into "iOS 12.2" version = version.replace(/^com\.apple\.CoreSimulator\.SimRuntime\.([^-]+)-([^-]+)-([^-]+)$/g, '$1 $2.$3') } // Making sure the version of the simulator is an iOS or tvOS (Removes Apple Watch, etc) if (!version.includes('iOS') && !version.includes('tvOS')) { continue } if (simulatorVersion && !version.endsWith(simulatorVersion)) { continue } for (const i in device) { const simulator = device[i] // Skipping non-available simulator if (simulator.availability !== '(available)' && // @ts-ignore verify isAvailable parameter simulator.isAvailable !== 'YES' && simulator.isAvailable !== true) { continue } const booted = simulator.state === 'Booted' const lastBootedAt = simulator.lastBootedAt const simulatorDescriptor = { udid: simulator.udid, name: simulator.name, booted, version } if (findOptions && findOptions.udid) { if (simulator.udid === findOptions.udid) { return simulatorDescriptor } } else { if (booted && simulatorName === null) { return simulatorDescriptor } if (simulator.name === simulatorName && !match) { match = simulatorDescriptor } // If no match found, use first available simulator that was booted before if (!!lastBootedAt && !match) { defaultMatch = simulatorDescriptor // CHANGED } // Keeps track of the first available simulator for use if we can't find one above. if (simulatorName === null && !match) { match = simulatorDescriptor } } } } return match ?? defaultMatch ?? null // ADDED }Reacted by Juan Pablo Bedoya MartínezReacted by Denis Slávik@adamTrz can we ship a release with this change as multiple users are surfacing it:
react/react-native#34866
react/react-native#34912Reacted by Stefan Wrobel, Le He, Bardiamist, Adam Trzciński, Sander in 't Hout, Rhys Powell and Carlos Solares
Environment
Description
Running
react-native run-ios --simulator='iPhone 13'no longer runs on iPhone 13 but the iPhone 12 Pro (first one available)It is working on our previous version
0.69.1with@react-native-community/cli@^8.0.0Reproducible Demo