gpt4 book ai didi

reactjs - 未定义的架构符号, react 原生 cocoapod 问题

转载 作者:行者123 更新时间:2023-12-03 14:18:22 26 4
gpt4 key购买 nike

我有一个现有的 React Native 应用程序,我想使用包含 PodSpecs 的新依赖项的 React-Native 链接。然而,这会带来一个问题,因为它们都依赖于 React。

我在我的 Podfile 中添加了以下内容:

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

# Explicitly include Yoga
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

这解决了其他模块的 PodSpec 的依赖问题,但引入了以下新错误:

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/thirdparty中。理想情况下,我希望指定 Podfile 中的路径,这样我就不必提交大量样板代码,但由于源文件没有 PodSpec,所以无法这样做。

是否有任何方法可以将 CxxBridge 链接到项目中,而无需添加 node_modules 中已存在的额外代码?其他人如何在第三方依赖项中使用 PodSpec(使用 React-Native 链接)?希望有任何帮助和/或 Podfile 示例

react-native: 0.57.1
xcode: 9.4.1

最佳答案

发布答案以防其他人遇到类似的情况。事实证明,链接的库是错误的,因为有些可能是从node_modules引用了React项目中的库,而有些可能是从React Pod引用了库。

修复步骤:

  • 删除 React 以及 React 项目中包含的任何子规范的链接。
  • 删除所有之前生成的 Pod 文件
  • 将安装后脚本添加到 Podfile
  • 运行pod install
  • 链接所有必需的 React 依赖项

安装后脚本:

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
end
end

关于reactjs - 未定义的架构符号, react 原生 cocoapod 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52617499/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com