【发布时间】:2018-10-02 22:54:26
【问题描述】:
我有一个现有的 react native 应用程序,我想将 react-native 链接与包含 PodSpecs 的新依赖项一起使用。然而,这带来了一个问题,因为它们都依赖于 React。
我在我的 Podfile 中添加了以下内容:
pod 'React', :path => '../node_modules/react-native'
# Explicitly include Yoga
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
这解决了来自其他模块的 PodSpecs 的依赖问题,但引入了以下新错误:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_RCTCxxBridge", referenced from:
objc-class-ref in libReact.a(RCTBridge.o)
ld: symbol(s) not found for architecture arm64
这个错误似乎是因为我没有列出 React 的任何子规范(特别是“CxxBridge”)。当我将 CxxBridge 添加到 Podfile 时,我不得不添加以下依赖项,因为“CxxBridge”依赖于 Folly:
# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
添加这些依赖项没有问题,但它们的源代码已经存在于node_modules/react-native/third-party 中。理想情况下,我希望在 Podfile 中指定路径,这样我就不必提交大量样板代码,但由于源文件没有 PodSpec,因此无法这样做。
有什么方法可以将 CxxBridge 链接到项目中,而不必添加 node_modules 中已经存在的额外代码?其他人如何在第三方依赖项中使用 PodSpecs(带有 react-native 链接)?非常感谢任何帮助和/或 Podfile 示例
react-native: 0.57.1
xcode: 9.4.1
【问题讨论】:
标签: reactjs react-native cocoapods