【React-Native】开发环境搭建 Mac M2

一、Node & Watchman & yarn

1. 安装brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. 安装Node & Watchman & yarn

brew install node
brew install watchman
npm install -g yarn

二、IOS

1. Ruby & rbenv

ruby --version //检查ruby版本
brew install rbenv ruby-build //安装rbuy版本管理工具rbenv


$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init - zsh)"

rbenv install  2.7.6 //安装指定版本
rbenv global 2.7.6	//设置ruby版本

2. Xcode & Command Line Tools & CocoaPods

Xcode 直接到 App Store下载安装即可

需要注意的是 检查 Xcode > Preferences > Locations 的Command Line Tools是否安装成功

brew install cocoapods //安装cocoapods

三、Android

1.Java Development Kit

brew tap homebrew/cask-versions
brew install --cask zulu11

2.Android Studio & Android SDK

1、下载 https://developer.android.google.cn/studio/ 

2、配置SDK Platform & SDK Tools
Android Studio > Preferences > Appearance & Behavior > System Settings > Android SDK

有两个选项卡 SDK Platform 和 SDK Tools 选择版本需要的安装即可

3.配置环境变量

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

四、检查环境

$ npx @react-native-community/cli doctor
Common
 ✓ Node.js
 ✓ yarn
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✓ JDK
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ CocoaPods - Required for installing iOS dependencies
 ✓ ios-deploy - Required for installing your app on a physical device with the CLI
 ✓ .xcode.env - File to customize Xcode environment

Errors:   0
Warnings: 0

五、创建项目 & 编译运行

npx react-native init xxx //xxx项目名称

//编译运行
yarn android
yarn ios
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值