Running multiple iOS simulators with React Native?

I got two separate react native apps running at the same time doing this

I entered the following in one terminal for the first app

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

After that finished building I opened another terminal and ran for the second app

react-native run-ios --simulator="iPhone XS" --port=8088

Then that built the second app on the new simulator and using a different port for the metro bundler. However after the second one built the first app changed its screen from the first app to the second app. I hit the home button and just re-opened the first app. One observation is that the first app seems to have both apps installed in the simulator while the second one does not.


This isn't the direct answer to your question, but I think it gives a better solution than running different simulators. You can check the following lib called ScreenSwitcher.

It basically use the same simulator, in our case iPhone 6 plus only and you can check and inspect any other smaller screen on it directly. I find that approach more efficient and faster.

ScreenSwitcher


Using MacOs Terminal, launch first simulator:

  1. cd /Applications/Xcode.app/Contents/Developer/Applications
  2. open -n Simulator.app
  3. cd <your react native project>
  4. react-native run-ios

Now, launch 2nd simulator:

  1. cd /Applications/Xcode.app/Contents/Developer/Applications
  2. open -n Simulator.app
  3. Click "Ok" when you get "Unable to boot device in current state"
  4. Change simulator to be different than first simulator (e.g. Hardware -> Device -> iPhone 6s)
  5. cd <react-native project>
  6. react-native run-ios --simulator "iPhone 6s" (or whatever simulator you chose in step 8).

Note: In the last step, you can disregard the terminal output since it indicates that it is launching using the 1st simulator hardware. In fact, it is launching into the 2nd simulator (as desired).

Tags:

React Native