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

M1芯片Mac执行arch -x86_64 pod install时Podfile报错

解决M1 Mac执行arch -x86_64 pod install时的Cannot read properties of undefined (reading 'configurations')错误

问题详情

在M1芯片Mac上执行arch -x86_64 pod install时,触发Podfile解析错误,核心报错:

[!] 无效的Podfile文件:767: unexpected token at 'TypeError: Cannot read properties of undefined (reading 'configurations')`

完整堆栈跟踪:

at Object.dependencyConfig (/Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/react-native/node_modules/@react-native-community/cli-platform-ios/build/config/index.js:102:37)
at /Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/@react-native-community/cli-config/build/loadConfig.js:35:61
at Array.reduce (<anonymous>)
at getDependencyConfig (/Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/@react-native-community/cli-config/build/loadConfig.js:31:51)
at get @mapbox/mapbox-sdk [as @mapbox/mapbox-sdk] (/Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/@react-native-community/cli-config/build/loadConfig.js:79:20)
at /Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/@react-native-community/cli-config/build/commands/config.js:15:51
at Array.forEach (<anonymous>)
at filterConfig (/Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/@react-native-community/cli-config/build/commands/config.js:14:38)
at Object.func (/Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/@react-native-community/cli-config/build/commands/config.js:25:32)
at Command.handleAction (/Users/qs033/Documents/locateBeeNewProject/LocateBee/node_modules/@react-native-community/cli/build/index.js:108:23)

错误指向Podfile第8行代码:

target 'LocateBee' do
    config = use_native_modules!

解决方案

  • 检查并修复@mapbox/mapbox-sdk依赖
    错误堆栈显示问题源于@mapbox/mapbox-sdk的配置读取,该包为纯JS工具包,无需原生模块配置:

    1. 打开项目根目录的package.json,确认该包版本是否与当前React Native环境兼容
    2. 删除node_modules、package-lock.json(或yarn.lock),重新执行npm install/yarn install
  • 修改Podfile过滤纯JS包
    调整use_native_modules!调用,添加排除规则跳过纯JS包的原生配置扫描:

    target 'LocateBee' do
        # 排除无需原生配置的纯JS包
        config = use_native_modules!(exclude: ['@mapbox/mapbox-sdk'])
    
  • 清理缓存并重新初始化

    1. 重置React Native缓存:npx react-native start --reset-cache
    2. 进入ios目录清理残留文件:
      cd ios && rm -rf Pods Podfile.lock Build
      
    3. 重新执行arch -x86_64 pod install
  • 对齐RN CLI与项目版本
    确保@react-native-community/cli和@react-native-community/cli-platform-ios版本与项目React Native版本匹配:

    1. 查看当前CLI版本:npm ls @react-native-community/cli
    2. 安装对应版本的CLI包(替换x.x.x为匹配版本号):
      npm install @react-native-community/cli@x.x.x @react-native-community/cli-platform-ios@x.x.x --save-dev
      

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 07:15:32