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
相关产品推荐
相关产品推荐

