Open iOS iPad simulator with React Native by default

By default, the simulator is the iPhone when you test the React Native app. I know there is a -simulator flag:

react-native run-ios --simulator 'iPad 2' 

Ok, but how to simulate a default ipad without this flag ...

Thanks!

+5
source share
3 answers

You can also use the "scripts" part of package.json:

 "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "ipad": "react-native run-ios --simulator 'iPad Air'" } 

And then run: npm run ipad

+6
source

The short answer is that you cannot change it, since the default value of the simulator is encoded in runIOS.js , especially on line 35 with default: 'iPhone 6' , which means that if the --simulator flag --simulator not specified, it is always will be iPhone 6.

From here, I think you have 4 options:

  • Continue to use the --simulator flag.

  • Create an alias for react-native run-ios --simulator 'iPad 2' , something like alias rnrii=react-native run-ios --simulator 'iPad 2' , which is essentially a shortcut to the command.

  • Find runIOS.js locally (perhaps somewhere in /usr/local/lib/node_modules and change the default simulator version

  • Come up with some local reaction-native-cli configurations and try combining them into a facebook/react-native repo.

+3
source

Close your simulator first

You can open the Xcode project from {YourApp} / ios / {YourApp} .xcodeproj

Then select the default simulator you want, and then create the application that will run on the new simulator.

then you can use run-ios to respond, and it will be launched according to the new standard!

enter image description here

+1
source

All Articles