DEV Community

vishal Raut
vishal Raut

Posted on

React-native commands and shortcuts

Purpose of the article

When developing an application in react-native we need to check our changes in both iOS and android platforms for simulator and emulator.
To do that we use native tools Xcode and Android studio.
The use of these tools might consume a lot of development time, especially if you are not a native developer.

Solution

As a solution, we can avoid using these tools until it is very necessary.
How we can do that huh?
Using terminal commands.
In this article I will be sharing a commands which helps me save my development time.

For iOS:

Commands

  • Clean build iOS build
> cd ios
> Xcodebuild clean
  • List the simulators
xcrun simctl list
  • Run ios build with specific simulator
react-native run-ios --simulator=<Your simulator name>
  • Clear pod cache and install again
> cd ios
> pod deintegrate
> rm -rf Podfile.lock 
> pod install

Shortcuts

  • Show/hide keyboard in simulator when input field is focused
command + shift + k
  • Clean build when from xcode
command + shift + k
  • Start build from xcode
command + b
  • Rotate the simulator
command + <right/left/top/bottom arrow>
  • Open debugging options:
command + d
  • Reloading simulator
command + r

Android

Commands

  • List connected devices
adb devices
  • Clean build
> cd android
> ./gradlew clean
  • Open debugging options
adb shell input keyevent KEYCODE_MENU
  • Open debugging options for specific device: Suppose emulator already open and the device is also connected then we can specify device id which will open debugging options for a specific device.
adb -s <Your device ID> shell input keyevent KEYCODE_MENU
  • Connect your packager with debug build: Suppose you have manually installed debug build in your device and you want to connect with package
adb reverse tcp:8081 tcp:8081
  • Log device errors in debug and release mode:
adb logcat AndroidRuntime:E *:S
  • Open emulator without android studio (MAC OS)
> cd ~/Library/Android/sdk/emulator
> ./emulator -list-avds
> ./emulator -avd  <emulator name>
> ./emulator -avd  <emulator name> -wipe-data
  • Run build for the specific device
react-native run-android deviceId=<DEVICE_ID>

Shortcuts

  • Open debugging options on emulator
command + m
  • Reload app on the emulator
r + r
  • Going to back navigation
Mac: command + delete
Windows: Cmd + Backspace
  • Open app overview
Mac: command + O
Windows: Cmd + O
  • Go to home
Mac: command + Shift + H
Windows: Cmd + Shift + H

Top comments (0)