Appendix B. Commands and Quickstart Guide
This appendix serves as a reference for some handy commands when working with React Native projects.
Creating a New Project
react-native init MyProject
Running on iOS
Open ios/MyProject.xcodeproj in Xcode. Click the Play button in the top-left. The React Native Packager should launch, as well as the iOS simulator.
Taking Screenshots on iOS
From the iOS simulator, pressing Command+S will save a screenshot to your desktop.
On a physical device, press the power and home buttons at the same time.
Running on Android
First, make sure you have an eligible device available.
To start an emulator, run:
android avd
Either create a new Android Virtual Device, or select an existing one and hit the Start… button.
Alternatively, you can attach a device via USB with USB debugging enabled. To enable USB debugging, go to Settings → About Phone → Build Number. Tap the Build Number seven times, until the device asks if you would like to enable development mode, and select “yes.”
Once you have completed either of those steps, run:
react-native run-android
This will install your application on the device and start the React Native Packager.
Taking Screenshots on Android
You can take screenshots on a physical device by holding down the power and volume-down buttons at the same time.
To take screenshots from the emulator: ensure that your emulator has SD card storage enabled. Then use the adb shell:
adb shell screencap -p /sdcard/screen.png adb ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access