react native 指定iphone模拟器型号运行

2021-05-18  本文已影响0人  next_discover

Step 1: Open the file

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js

Step 2: Change a line of code, from this:

if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {
  continue;
}

to this:

if (!version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') && !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')) {
  continue;
}

Step 3:
after update to Xcode 11 xcrun returns true or false and not YES or NO as before.

goto

/node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js 

find

if (
   simulator.availability !== '(available)' &&
   simulator.isAvailable !== 'YES'
 ) {
  continue;
}

and change it to

if (
   simulator.availability !== '(available)' &&
   simulator.isAvailable !== true
 ) {
  continue;
}

react-native run-ios --simulator="iPhone 11"

上一篇下一篇

猜你喜欢

热点阅读