【问题标题】:Undefined symbols for architecture, react native cocoapod issues建筑的未定义符号,反应原生 cocoapod 问题
【发布时间】: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


    【解决方案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
    

    【讨论】:

    • 你是一个救生员。
    猜你喜欢
    • 1970-01-01
    • 2022-12-16
    • 1970-01-01
    • 1970-01-01
    • 2019-07-30
    • 2017-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多