Run app on iOS simulator and Android emulator at same time
Just as personal documentation, these are the steps I've needed to follow to run an Android emulator and iOS simulator, side by side, both with live reload enabled.
- I've needed to install Watchman with
brew install watchman
. - I've also needed to install the React Native CLI with
npm install -g react-native-cli
. - Pretty obvious, I already had both Xcode and Android Studio installed on my Mac.
iOS simulator
- With
react-native run-ios
I launch the React Packager. Same thing can be done withnpm run ios
providedpackage.json
contains ascripts
section like this:
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "node node_modules/jest/bin/jest.js"
}
- At this point, the iOS simulator gets opened automatically and loads the app. I can reload it every time after saving changes in the code using βR in the simulator. Even better, live reload can be enabled from the developer menu (Hardware > Shake Gesture).
Android emulator
- First of all, I need to manually open an Android emulator using
~/Library/Android/sdk/tools/emulator -avd Nexus_4_API_25
(more details about this command at Run AVD emulator without running Android Studio). - With
react-native run-android
I launch the React Packager. Same thing can be done withnpm run android
(again, providedpackage.json
contains ascripts
section as stated above). - At this point, the Android emulator loads the app. Live reload can be enabled from the developer menu (βM).