You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo环境安装react-native-mmkv后构建时pod install失败求助

解决Expo环境中react-native-mmkv安装后iOS构建失败的问题

问题重现

在Expo项目中安装react-native-mmkv,执行npx expo prebuild后,运行npx expo run:ios时触发以下错误:

⚠️ 在ios目录中运行pod install时出错。
命令pod install执行失败。
└─ 原因:安装MMKVCore出错
[!] /usr/local/bin/git clone https://github.com/Tencent/MMKV.git /var/folders/v6/8yrsb82d0j1ckkc8dccwm70c0000gn/T/d20240711-4366-2smlq1 --template= --single-branch --depth 1 --branch v1.3.7

正在克隆到'/var/folders/v6/8yrsb82d0j1ckkc8dccwm70c0000gn/T/d20240711-4366-2smlq1'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
error: 3689 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

解决方案

这个错误本质是git克隆MMKV仓库时的网络传输中断,可按以下步骤逐一尝试:

  • 增大git网络传输限制
    终端执行以下命令提升git的网络参数:

    git config --global http.postBuffer 524288000
    git config --global http.maxRequestBuffer 100M
    git config --global core.compression 0
    

    之后重新运行npx expo run:ios。

  • 手动克隆MMKV并让pod指向本地路径

    1. 在本地任意目录克隆指定版本的MMKV仓库:
      git clone --single-branch --depth 1 --branch v1.3.7 https://github.com/Tencent/MMKV.git
      
    2. 打开项目的ios/Podfile,找到MMKVCore的依赖配置,替换为本地克隆路径(示例路径为~/Documents/MMKV):
      pod 'MMKVCore', :path => '~/Documents/MMKV'
      
    3. 进入ios目录执行pod install,再回到项目根目录运行npx expo run:ios。
  • 清理缓存后重试
    执行以下命令清理Expo和pod的缓存:

    npx expo prebuild --clean
    rm -rf ios/Pods ios/Podfile.lock
    pod cache clean --all
    

    重新执行npx expo prebuild和npx expo run:ios。

  • 切换网络环境
    如果当前网络不稳定,尝试切换到其他网络(比如手机热点),同时检查是否有代理、防火墙阻止了git的HTTPS请求。

内容的提问来源于stack exchange,提问作者Web_Dev_Ary

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 07:43:15