一、 React Native 学习之环境搭建

安装依赖

1、必须安装的依赖有:Node、Watchman 和 React Native 命令行工具以及 Xcode。
2、安装Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3、使用Homebrew来安装 Node 和 Watchman。在命令行中执行下列命令安装:
brew install node
brew install watchman
4、npm 镜像以加速后面的过程
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global

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

npm install -g yarn react-native-cli
安装完 yarn 后同理也要设置镜像源:
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

Xcode

启动 Xcode,并在Xcode | Preferences | Locations菜单中检查一下是否装有某个版本的Command Line Tools。Xcode 的命令行工具中包含一些必须的工具

创建新项目

react-native init testProject

编译并运行 React Native 应用

cd testProject
react-native run-ios

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 少小识花容,惜留一抹影。 今日偶翻书,扶桑是汝名。 羲和此驾车, 华光耀天明。 金乌落且安,羿断三界行。 修得百...
    风泗水阅读 413评论 0 5

友情链接更多精彩内容