之前公司搞了一套RN的项目,没事学习一下~
1、安装Homebrew
1.1Homebrew是Mac系统的包管理器,用于安装NodeJS和一些其他必需的工具软件
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
1.2使用Homebrew来安装Node.js,设置npm镜像
brew install node
1.3设置淘宝镜像
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
1.4安装React Native的命令行工具(react-native-cli)
npm install -g react-native-cli
2、安装iOSIDE,Xcode。
3、安装 Node, Watchman
brew install node
brew install watchman
4、安装Yarn
4.1Yarn是 Facebook 提供的替代 npm 的工具,可以加速 node 模块的下载
npm install -g yarn
4.2安装完 yarn 后同理也要设置镜像源
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
最后
react-native run-ios
如果出现,如下类似错误
Found Xcode project CssStyle.xcodeproj
xcrun: error: unable to find utility "XXXXX", not a developer tool or in PATH
Command failed: xcrun simctl list devices
xcrun: error: unable to find utility "XXXXX", not a developer tool or in PATH
去x-code配置一下命令行工具(Command Line Tools)即可
屏幕快照 2019-05-07 下午2.19.37.png