mac搭建react-native开发环境记录
首先安装Homebrew什么是Homebrew呢?Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn’t include with OS X. 官方的解释非常明了,Homebrew是一个包管理器,用于在Mac上安装一些OS X没有的UNIX工具(比如著名的wget),能在Mac中方便的
首先安装Homebrew
什么是Homebrew呢?Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn’t include with OS X. 官方的解释非常明了,Homebrew是一个包管理器,用于在Mac上安装一些OS X没有的UNIX工具(比如著名的wget),能在Mac中方便的安装软件或者卸载软件,可以说Homebrew就是mac下的apt-get、yum神器。
Brew安装方法很多种,我用一种终极方法一键就搞定
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
如果这种方法你搞不定你自己看看其他安装的方法。
安装了Homebrew后,我们安装node
安装node
brew install node
好像是可以指定版本的 (这样:brew install node@14.17.5)你自己试试。
由于这样安装太慢,我等不了,我的node实际是 下载pkg ,然后运行安装的,下载地址:
https://nodejs.org/download/release/v14.17.5/
安装Watchman
brew install watchman
安装Cocoapods
brew install cocoapods
实际我没有用这个方法安装cocoapods,我是使用gem安装的
gem sources -l
gem source -r https://rubygems.org/
gem source -a https://gems.ruby-china.com/
sudo gem install cocoapods
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git ~/.cocoapods/repos/trunk
验证 pod是否可用
pod --version
安装react-native-cli
npm install react-native-cli -g
发现安装目录没有权限,然后我chmod -R 777 /dir给目录授权可写权限后安装react-native-cli成功了
但是我在 init react native项目时候cocoapods出错了。
后来这么解决:
pod repo 换源
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
pod repo
cd ~/.cocoapods/repos
pod repo remove master
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master
然后进入react native 目录中ios目录
pod install
这样正常安装了,但是碰到“Installing glog (0.3.5) 安装报错”
在RN项目根目录:
sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install
这样就解决了这个问题
然后
npm run ios,就开始启动模拟器,开始编译自动安装了。
更多推荐

所有评论(0)