安装依赖

必须安装的依赖有:Node、Watchman 和 React Native 命令行工具以及 Xcode。

Node, Watchman

在命令行中执行下列命令安装:

  1. brew install node
  2. brew install watchman
  3. npm config set registry https://registry.npm.taobao.org --global
  4. npm config set disturl https://npm.taobao.org/dist --global

Yarn、React Native 的命令行工具(react-native-cli)

在命令行中执行下列命令安装:

  1. npm install -g yarn react-native-cli
  2. yarn config set registry https://registry.npm.taobao.org --global
  3. yarn config set disturl https://npm.taobao.org/dist --global

创建新项目

在命令行中执行下列命令创建新项目:
react-native init Myapp
你也可以使用 –version 参数创建指定版本的项目如:
react-native init MyApp --version 0.44.3

编译并运行 React Native 应用

在项目目录中运行react-native run-ios

  1. cd Myapp
  2. react-native run-ios

也可以直接打开Xcode运行

运行结果

React Native Mac下环境搭建

相关文章:

  • 2021-07-04
  • 2021-10-17
  • 2022-12-23
  • 2021-11-10
  • 2021-10-30
  • 2021-08-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-22
  • 2021-06-28
  • 2022-12-23
  • 2021-09-14
  • 2021-10-13
相关资源
相似解决方案