按照中文网一步一步往下:
1.先安装这个brew ,打开网址:https://brew.sh里头有安装指令:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
安装完brew,就可以安装node ,watchman,yarn,cocoapods
如果安装brew报错:
Failed to connect to raw.githubusercontent.com port 443: Connection refused
打开此网站(https://githubusercontent.com.ipaddress.com/raw.githubusercontent.com
)查看raw.githubusercontent.com 的ip地址,然后修改 /etc/hosts 文件,新增:
# 你查到的IP地址
199.232.68.133 githubusercontent.com
brew install node
brew install watchman
# 使用nrm工具切换淘宝源
npx nrm use taobao
npm install -g yarn
brew install cocoapods
最后就是:
cd AwesomeProject
yarn ios
# 或者
yarn react-native run-ios
会有一个报错:
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./iosProject/ios && pod install".
这个没事,按照提示:
#先设置xcode路径
sudo xcode-select --switch /Applications/Xcode.app
cd ./iosProject/ios && pod install