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

React Native从0.66.3升级至0.68.2时执行pod install触发use_native_modules!相关错误求助

Fixing "Cannot read properties of undefined (reading 'configurations')" in React Native 0.68.2 Pod Install

The error you're encountering is almost certainly tied to a version mismatch between the React Native CLI and your project's target React Native version. Here's how to resolve it step by step:

1. Downgrade the React Native CLI to a compatible version

Your project currently uses @react-native-community/cli@8.0.2, which is built for React Native 0.70+. React Native 0.68.2 requires CLI version 7.0.3 to function correctly.

Update your package.json devDependencies section:

"@react-native-community/cli": "7.0.3"

Then reinstall your dependencies to apply the change:

rm -rf node_modules yarn.lock
yarn install

2. Verify your Podfile setup

Ensure your ios/Podfile matches the standard structure for React Native 0.68.2:

  • At the top, include these required imports:
    require_relative '../node_modules/react-native/scripts/react_native_pods'
    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    
  • Confirm the minimum iOS platform version is set correctly (RN 0.68 requires iOS 12.4+):
    platform :ios, '12.4'
    
  • Make sure the use_native_modules! call is placed inside your target block:
    target 'app' do
      config = use_native_modules!
      # Rest of your target configuration goes here
    end
    

3. Clear caches and perform a fresh pod install

After updating dependencies and fixing the Podfile, clear all cached data to eliminate any leftover conflicts:

# Clean node modules and yarn cache
rm -rf node_modules
yarn cache clean

# Clean iOS pod artifacts
cd ios
pod deintegrate
pod cache clean --all
rm -rf Pods Podfile.lock

# Reinstall pods (use arch -x86_64 for M1/M2 chips)
arch -x86_64 pod install

4. Double-check native module compatibility

While the CLI mismatch is the primary cause, confirm your native dependencies support React Native 0.68.2:

  • Most of your listed packages (like react-native-svg, react-native-vector-icons) have versions compatible with RN 0.68, but if you hit issues later, consider updating to their latest compatible releases.
  • Avoid deprecated tools like react-native-eject which can introduce unexpected conflicts.

Why this happens

The use_native_modules! helper in CLI v8 includes breaking changes that don't align with React Native 0.68's internal setup. When the CLI tries to access configurations from an undefined object (caused by the version mismatch), it throws the error you're seeing. Downgrading the CLI to the correct version restores the expected behavior of this helper function.

内容的提问来源于stack exchange,提问作者Gergő Horváth

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 22:12:46