Instructions

Version 1.5

Introduction

React Native allows developers to use web-like syntax to create mobile apps from native components for iOS and Android. Since you can't normally build iOS apps on Windows, this tutorial will focus on iOS for Mac users and Android for Windows users.

You will be using a tool called Expo that simplifies development and publication of your app, as well as letting you test directly in a special app on your physical phone. For the record, compared to the React Native CLI (Command Line Interface) approach, Expo limits the number of native libraries you can use, though you can "eject" the Expo code for more sophisticated development afterward in the React Native CLI. This diagram shows how React Native's various helpers interact.

Follow all Expo instructions below, as well as or depending on your platform. ( instructions were last tested in spring 2019 and may be outdated.)

Overview

Codecademy explanation

🍿 Videos

  1. Introduction
  2. Creating an Expo App
  3. Testing the App with Expo Go
  4. Modifying & Debugging the App
  5. Recap

Install support apps (30+ minutes)

Everyone

Expo Go phone app

Visual Studio Code

Optional Visual Studio Code extensions

MacOS

required: Xcode from the App Store or Web
optional: Android Studio from the Web (see below)

Windows

Download Android Studio from the Web

Install Java (~10 minutes)

Install NodeJS (~5 minutes)

Install Python 2 (~5 minutes)

Enable shell commands

When instructed to type Terminal commands below:


		C:\WINDOWS\system>[type your command here]
	

⚠️ Command Prompt is a powerful program, so proofread every command you type into it.

Create a React Native folder

Everyone

MacOS

Install node (~5 minutes)

Everyone

Install Expo (~5 minutes)

Everyone

Install the Expo Command Line Interface

Navigate to your React Native folder (~1 minute)

Initialize your React Native project (~5 minutes)

Launch your React Native project

Everyone

Launch Chrome

Launch React Native (~5 minutes)

Editing your project

Everyone

Customizing your emulator

Everyone

To change settings on your virtual simulators

To show the debugging menu on your phone

MacOS

To refresh your simulator:

To show the debugging menu on your simulator:

Windows

To refresh your Android simulator:

To show the debugging menu on your simulator:

To close or restart your React Native project

Everyone

Debugging your emulator

Problem: Simulator shows home screen, not your app

Click and drag to the right to look for your app icon, then double-click to open it.

Problem: "No bundle URL/packager running" error

Running react-native run-ios on some Apple computers results in an error like, "No bundle URL present. Make sure you’re running a packager server or have included a .jsbundle file in your application bundle." The phone simulator isn't working, apparently because there's no packager, and the packager isn't launching in a new Terminal window, apparently because it's not recognizing node.

One solution is to install enough react-native to run the Metro bundler in one Terminal window, then open another Terminal and install node again, launching the simulator from there. Try these steps, assuming you've already installed the React Native CLI and initialized a project called, say, petfinder, and that you've quit the Terminal and Simulator.

1. Delete stale files

In Finder, navigate to your petfinder folder.

Delete petfinder/node_modules.

Delete petfinder/package-lock.json.

Open Terminal and navigate to your petfinder directory (easily done by dragging your petfinder folder onto the Terminal icon in dock).

2. Reinstall nvm, node, and dependencies

Re-install nvm (node version manager)


		MyComputer:petfinder marykate$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
	

When prompted, paste and run the two followup nvm commands that appear at the end; they'll look something like:


		MyComputer:petfinder marykate$ export NVM_DIR="/Users/marykate 1/.nvm"
		MyComputer:petfinder marykate$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
	

Re-install node:


		MyComputer:petfinder marykate$ nvm install 9.11.1
	

Re-install your dependencies:


		MyComputer:petfinder marykate$ npm install
	

3. Start the packager


		MyComputer:petfinder marykate$ react-native start
	

(Metro will run in this Terminal window)

4. Reinstall node in a new Terminal

In Finder, drag your petfinder folder onto Terminal in your dock to open a new window there.


		MyComputer:petfinder marykate$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
	

When prompted, paste and run the two followup nvm commands as before.


		MyComputer:petfinder marykate$ nvm install 9.11.1
	

(May not be necessary.)

5. Start the simulator from the new Terminal


		MyComputer:petfinder marykate$ react-native run-ios 
	

(This takes 5 minutes--don't interact with phone until Terminal puts you back at a prompt).

With luck, you'll see the "Welcome to React Native" screen in your phone simulator!