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

npm install成功后执行pod install出现No podspec found for `React`错误求助

Fixing "No podspec found for React in ../node_modules/react-native" Error

Hey there, sorry you're hitting this frustrating pod install error—let's work through it step by step. This issue usually means CocoaPods can't locate the React.podspec file at the path you've specified, or there's a problem with your React Native dependency setup. Here are the most reliable fixes:

1. Double-check the react-native path in your Podfile

Your current react_native_path = '../node_modules/react-native' assumes your ios folder is one level below your project root (where node_modules lives). If your project structure is different (e.g., ios is nested inside a subfolder like app/ios), you'll need to adjust the path to match.

  • To verify the path is correct: Open Terminal, navigate to your ios folder, and run ls ../node_modules/react-native. If you get a "No such file or directory" error, update the path in your Podfile (e.g., ../../node_modules/react-native for a nested ios folder).

2. Ensure React.podspec exists in your react-native directory

Sometimes npm install doesn't fully install all React Native files, or there's corruption in your dependencies. Let's reset and reinstall:

  • Navigate back to your project root directory.
  • Delete the node_modules folder, package-lock.json (or yarn.lock if using Yarn).
  • Re-run npm install (or yarn install) to fetch fresh dependencies.
  • Check if React.podspec exists in node_modules/react-native. If it does, try running pod install again from the ios folder.

3. Update your Podfile for React Native >= 0.60

If you're using React Native 0.60 or later, your manual subspec setup is outdated. React Native now uses autolinking to simplify pod management. Replace your current React/Yoga configuration with this modern setup:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'YourAppName' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # Set to `true` to enable Hermes (optional)
    :hermes_enabled => false
  )

  # Add your other pods here (e.g., third-party libraries)
end

Don't forget to replace YourAppName with your actual app target name, then run pod install again.

4. Clean CocoaPods cache

Cached pod data can sometimes cause mismatches. Run these commands from your ios folder to clear everything and start fresh:

pod deintegrate
pod clean
rm -rf Podfile.lock
pod install

If none of these fixes work, check your React Native version with react-native --version in your project root, and confirm your Podfile is compatible with that specific version.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:03:07