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

React Native iOS Podfile配置错误及Xcode项目读取异常求助

React Native iOS Podfile配置错误及Xcode项目读取失败问题

问题概述

iOS端执行pod install时触发Podfile配置错误,提示Invalid Podfile file: exit,同时无法移除指定build目录;通过npm start启动应用并打开模拟器后,出现xcodebuild: error: Unable to read project 'copiaReactnativeApp.xcodeproj'错误。

原Podfile内容

use_modular_headers!

#platform :ios, '15.0'  # Specify the minimum iOS version
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

target 'copiaReactnativeApp' do
  use_react_native!(
    :path => use_native_modules![:reactNativePath],
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    :hermes_enabled => true
  )

  target 'copiaReactnativeAppTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    react_native_path = use_native_modules![:reactNativePath]
    react_native_post_install(
      installer,
      react_native_path,
      :mac_catalyst_enabled => false
    )
  end
end

pod install完整错误日志

Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration
Auto-linking React Native modules for target `copiaReactnativeApp`: Picker, RNCMaskedView, RNCPicker, RNFBApp, RNGestureHandler, RNReanimated, RNScreens, react-native-config, react-native-image-picker, and react-native-safe-area-context
Framework build type is static library

[!] Invalid `Podfile` file: exit.

 #  from {path}/ios/Podfile:13
 #  -------------------------------------------
 #  target 'copiaReactnativeApp' do
 >    use_react_native!(
 #      :path => use_native_modules![:reactNativePath],
 #  -------------------------------------------

[!] Unable to remove the content of {path}/copia-react-native-app/ios/../ios/build/generated/ios folder. Please run rm -rf {path}/copia-react-native-app/ios/../ios/build/generated/ios and try again.

尝试过的修改及新错误

  • 添加react_native_post_install插件配置到Podfile:
plugin 'react_native_post_install', {
  'react_native_path' => '../node_modules/react-native',
  'use_modular_headers' => true
}
  • 修改use_react_native的path为固定路径:
platform :ios, '15.0'

target 'copiaReactnativeApp' do
  use_react_native!(
    :path => '../node_modules/react-native',
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    :hermes_enabled => true
  )
end

执行上述修改后出现新错误:

Your Podfile requires that the plugin `react_native_post_install` be installed. Please install it and try installation again.

已执行的排查操作

  • 卸载重装Cocoapods
  • 执行npx pod-install、pod install
  • 执行gem install cocoapods-react-native-post-install、gem update --system
  • 执行pod cache clean --all、bundle install、pod setup

环境版本信息

  • react-native: 0.73.4
  • react-native-cli: 2.0.1
  • Ruby: 3.0.0
  • Cocoapods: 1.15.2

寻求上述问题的解决方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 20:15:28