Search code examples
iosxcodereact-nativeios-simulatorreact-native-ios

React Native set default iPhone simulator


I want to set a default simulator for my react native project so if I run the script yarn ios or npx react-native run-ios it always start the "iPhone 12 Pro Max".

  • using the --simulator flag once does not change the default simulator, and the next time I run yarn ios or react-native run-ios it starts on different simulator
  • When I run yarn ios the app starts with iPhone 10 and when I run npx react-native run-ios the app starts with iPhone 8. If I remove either of these simulators via xCode, the project does not start with mentioned scripts and throws an error that iPhone 10 or iPhone 8 was not found.

So my question is where in the project the value of these simulators are saved, and how to change it. Is it set somewhere in .xcworkspace or .xcodeproj? If someone clones this project and runs the app might start on different devices on their machine.

Note: I am not searching for answers including setting --simulator flag


Solution

  • There is currently no official way besides --simulator to set device for run-ios as doc

    You can try to edit in ./node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js the default in end of file:

    var _default = {
    ...
    options: [{
        ...
        default: 'iPhone 8'
      },
    ...
    }
    

    "react-native": "0.63.4"