React-native 错误:无效的 `Podfile` 文件:退出。 “无法安装 Pods。正在更新 Pods 项目并重试...”

问题描述 投票:0回答:1

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

我会得到这个错误:

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.

然后我尝试添加:

plugin 'react_native_post_install', {
  'react_native_path' => '../node_modules/react-native',
  'use_modular_headers' => true
}

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 缓存清理 --all、捆绑安装、pod 设置

我仍然可以通过使用

npm start
然后打开我的模拟器来运行我的应用程序。但它确实给了我这个错误:

Error: xcodebuild: error: Unable to read project 'copiaReactnativeApp.xcodeproj'.

版本


反应原生:0.73.4

react-native-cli:2.0.1

红宝石:3.0.0

可可足类:1.15.2

react-native cocoapods
1个回答
0
投票

我通过执行以下操作修复了它

  1. 运行
    whoami
    获取当前用户。
  2. 奔跑:
    sudo chown -R ownerName: /path/to/node_modules

我从这个评论找到了它。

© www.soinside.com 2019 - 2024. All rights reserved.