Skip to main content

Set Up Your React Native Development Environment

What You’ll Learn

In this step, you’ll learn:
  • The software setup required for React Native development.
  • How to install the forcereact utility.
  • How to install the yarn utility.
  • How to install the TypeScript compiler.

Prerequisites

  • Successful completion of step 1, Install Common Components.
  • One of the following:
    • A macOS X development machine and successful completion of step 2, Install the iOS Development Environment, or step 3, Install the Android Development Environment, or both.
    • A Windows development machine and successful completion of step 3, Install the Android Development Environment.

About the React Native Development Environment

If you’ve come this far, you’re perfectly positioned to install the tools for developing Mobile SDK React Native apps.

React Native development requires the Mobile SDK common software and at least one native development environment—Android on Windows; Android, iOS, or both on macOS X. If you jumped into this project here, without doing any of the previous steps, go back and start at step 1. Then continue to a native development installation before returning here.

Once you’ve installed either the Android or the iOS development environment, enabling the React Native option is easy. The only missing pieces are forcereact, yarn, and the TypeScript compiler.

You can develop React Native apps on either Mac or Windows development machines, but you can’t do iOS development on a Windows machine.

Install Yarn

Mobile SDK uses yarn internally as a dependency manager.
  1. Open the Terminal app on Mac, or the command prompt on Windows.
  2. To install yarn:
    • On a Mac, type sudo npm install -g yarn and press Return.
    • On Windows, type npm install -g yarn and press Return.
  3. To verify your installation, type yarn version and press Return.
For more information, see yarnpkg.com.

Install the TypeScript Compiler

In Mobile SDK 9 and later, you can choose to write your React Native code with either standard JavaScript or TypeScript--or both! Because Mobile SDK libraries use TypeScript, the compiler tool is required regardless of whether your code uses TypeScript.
  1. Open the Terminal app on Mac, or the command prompt on Windows.
  2. To install the TypeScript compiler:
    • On a Mac, type sudo npm install -g typescript and press Return.
    • On Windows, type npm install -g typescript and press Return.
  3. To verify your installation, type tsc -v and press Return.
For more information, see www.typescriptlang.org.

Install Forcereact

To create React Native apps for Mobile SDK, you use a node.js command-line utility named forcereact. Forcereact is the quickest and easiest way to create React Native apps for Mobile SDK. You just enter some metadata as prompted, and a few minutes later you’re ready to develop on iOS, Android, or both.

  1. Open the Terminal app on Mac, or the command prompt on Windows.
  2. If you’re planning to develop on Android, define an ANDROID_HOME system variable that points to your installed Android SDK. For example, on a Mac, the path is typically /Users/<username>/Library/Android/sdk. Be sure to store the variable in your persistent environment settings so that you don’t have to keep retyping it.
  3. To install forcereact:
    • On a Mac, type sudo yarn global add forcereact and press Return. If prompted, enter your system password.
    • On Windows, type yarn global add forcereact and press Return.
  4. To verify your installation, type forcereact version and press Return.
  5. To view forcereact usage information, type forcereact and press Return.

Congratulations! If you’ve completed this step, you’re ready to create React Native apps. To get started, use the forcereact create command. You specify which platforms to support––iOS, Android, or both––as well as some app metadata.

Remember, if you installed only one native development environment, you can come back at any time to install the other one. Just check to be sure that your current Mobile SDK components are up to date with the versions listed in this project.

We won’t check any of your setup. Click Verify Step.

Formez-vous gratuitement !
Créez un compte pour continuer.
Qu’est-ce que vous y gagnez ?
  • Obtenez des recommandations personnalisées pour vos objectifs de carrière
  • Mettez en pratique vos compétences grâce à des défis pratiques et à des questionnaires
  • Suivez et partagez vos progrès avec des employeurs
  • Découvrez des opportunités de mentorat et de carrière