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

新React Native项目Podfile无效,执行pod install报错求助

解决React Native项目Podfile引入Expo autolinking导致的pod install错误

修复步骤

  1. 打开iOS目录下的Podfile,删除顶部那行Expo相关的require代码:
    require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
    
  2. 确保Podfile使用React Native官方的默认配置,标准结构如下(替换成你的项目名称):
    require_relative '../node_modules/react-native/scripts/react_native_pods'
    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    
    platform :ios, '13.0'
    
    target 'YourProjectName' do
      config = use_native_modules!
    
      use_react_native!(
        :path => config[:reactNativePath],
        :hermes_enabled => false # 如需启用Hermes可改为true
      )
    
      target 'YourProjectNameTests' do
        inherit! :complete
      end
    
      use_flipper!()
    
      post_install do |installer|
        react_native_post_install(installer)
        __apply_Xcode_12_5_M1_post_install_workaround(installer)
      end
    end
    
  3. 在ios目录下重新执行命令:
    pod install
    

可能的原因

  • 你可能无意中使用了包含Expo依赖的项目模板初始化RN项目
  • 部分第三方RN库可能会自动注入Expo相关的配置代码到Podfile中
  • React Native CLI的特定版本可能存在bug,导致错误生成了带有Expo代码的Podfile

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 06:21:37