使用Podfiles集成react-native时如何集成react-native-video?

How to integrate react-native-video when using Podfiles to integrate react-native?

在 iOS 的安装说明中,它说 运行

react-native link

完成后我看到:

但是,编译立即失败并出现错误 React/RCTViewManager.h not found:

查看 integration instructions on Facebook's website 时,它让我们使用 Podfile。当您使用 Podfile 时,您的项目如下所示:

对比一下react native的示例工程,可以看出其实它根本没有使用Podfile来集成react native;相反,所有 React 组件都作为库包含在内:

因此,我怀疑 react-native-video 的集成说明与 integration instructions found here 不兼容。

谁能推荐一下使用Podfiles集成react-native时如何集成react-native-video?

您使用的是什么版本的 React Native?这看起来是由于 breaking change for RN version >0.40.

此问题的简短修复是,如果您在本机代码中看到 #import React/$(filename),请将其替换为 #import "$(filename)",但如果您可以更新到 RN >0.40,那将更可取。

要回答关于 pods 的问题,您应该能够将 pod 'react-native-video', :path => '../node_modules/react-native-video' 之类的内容添加到您的 podfile 和 运行 pod install(如果您的相对路径库根目录的 Podfile 不正确,用正确的替换它)。查看 react-native-video 的 github 页面,它确实有一个 podspec,所以它 可能 支持 cocoapods 安装