在`../node_modules/react-native/Libraries/FBReactNativeSpec`中未找到`FBReactNativeSpec`的Podspec文件。

23

我已经将react-native升级到0.64版本,运行pod install后出现了这个错误。

No podspec found for `FBReactNativeSpec` in `../node_modules/react-native/Libraries/FBReactNativeSpec`

我尝试删除node_module,删除pod文件,取消集成,但仍然遇到了这个问题。

有什么帮助吗?

4个回答

58

ReactNative的新版本(从0.64开始)将FBReactNativeSpec存储在另一个文件夹中。 您需要在Pod声明中使用新路径替换旧的FBReactNativeSpec路径。

打开您的Podfile并找到这一行:

pod 'FBReactNativeSpec', :path => "./node_modules/react-native/Libraries/FBReactNativeSpec"

使用这个路径替换原来的路径:

pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/FBReactNativeSpec"

8
在升级至新版本的React Native 0.64.1时,当我尝试进行pod install时,遇到了上述错误。我通过像下面这样替换podfile中的内容来解决了这个问题:

https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.64.1/RnDiffApp/ios/Podfile

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

platform :ios, '10.0'

target 'RnDiffApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
  end
end

我按照上面的方式更改了我的podfile,然后在终端上尝试了pod install,一切都运行正常。


2
尝试使用 npx react-native-clean-project 命令 在所有提示中输入“Y”。

2
谢谢。我们已经成功修复了问题,更新了所有的软件包。使用最新版本的React 0.64,Podfile会以完全不同的方式生成。导入会自动链接,因此您不需要再进行导入。此外,我们还必须更新AppDelegate.m文件。我们发现这个链接非常有用,因为您可以比较不同版本的React并查看更改内容。 https://react-native-community.github.io/upgrade-helper/ - Paolo
@Paolo,你能否提供一些有关你更新的软件包的详细信息?我按照升级助手的说明进行了操作,但仍然遇到了与你相同的错误。 - lama
我已经将我的当前打包程序复制到升级助手页面(上面的链接),然后根据结果只需更改版本即可。希望这对您有用。另外,随着React和Xcode的最新更新,您必须确保您的podfile具备所有要求。我发现这个链接非常有帮助。看一下@lama https://exerror.com/react-native-0-64-wont-build-ios-app-after-updating-xcode-to-12-5-and-ios-to-14/ - Paolo

1
我最近也有同样的问题,发现是因为我运行了命令npm audit fix。它自动更新了React Native版本,导致podfile出现混淆。降级你的rn包或重置你的版本控制应该会起作用。

谢谢,我建议升级到最新版本,因为这样更容易处理和理解Podfile。 - Paolo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接