I want to run my react native app twice: my device + simulator.
I don't mind using two metro bundler instances. How can I do that?
Right now, both my devices connect to 8081 - and whenever one connects, it kicks the other one off.
(I first built from XCode to my device/simulator, and then I run react-native start
)
npx react-native run-ios --device "Kasra’s iPhone"
, of course replace Kasra’s iPhone
with the name of your real ios device.npx react-native start --port 8082
Ctrl + D
to open the dev menu, or shake the device to open it.Configure Bundler
optionifconfig
or ipconfig
in terminal to find your IP based on your OS.8082
Apply Changes
, it should automatically start the app on your ios real devicenpx react-native run-ios
to run it on your simulator.Now you have two bundlers running side by side on ports 8081 and 8082 simultaneously.
react-native run-ios
command supports a port
parameter after this commit. You can try to use this parameter to run your app in two different ports with two different builds.
From commit notes:
adds
--port
option toreact-native run-ios
as well as patches port …Summary: The pull request adds the
--port
option torun-ios
allowing a developer to build and launch a react-native app using a single command line like this:react-native run-ios --port 8088
It defaults to the current port 8081.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With