Skip to content

环境搭建

  1. 下载 rbenv
shell
# .zshrc
eval "$(rbenv init -)"
  1. rbenv install ruby 3.3.0 & set 3.3.0 global
  2. workspace 下
shell
# 1. install js dependencies
# or yarn install
npm install
# 2. pod install dependencies
# 不要使用cd ios & pod install 这种安装兼容性没有包管理工具安装的好
npx pod-install

Or

shell
# 使用pnpm安装依赖,这种安装有个弊端:
# andriod/settings.gradle includeBuild('../node_modules/@react-native/gradle-plugin') node_modules目录需要修正成../node_modules/.pnpm/.../xxx
pnpm install
pnpm pod-install

Debug

选用工具:react-native-debugger 打开调试:

  1. 运行后在 Metro Cli 中按 D 键打开调试弹窗,点击 Start Debug
  2. 如果未出现这个项
  • IOS: 在 Podfile 文件中关闭 hermes
shell
:hermes_enabled => false,

QA

Q: ios 运行项目后改动代码没有热重载 A: 查看 ios/.../[projectName].xcscheme, 将 buildConfiguration 改为 Debug

xml
<LaunchAction
  buildConfiguration = "Debug">
</LaunchAction>