切换到调试时架构 x86_64 的未定义符号

Posted

技术标签:

【中文标题】切换到调试时架构 x86_64 的未定义符号【英文标题】:Undefined symbols for architecture x86_64 when switching to Debug 【发布时间】:2017-11-30 20:59:34 【问题描述】:

当我将方案切换到调试时出现以下错误。在 Release 中,我可以毫无问题地构建。

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RCTReconnectingWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTPackagerConnection.o)
  "_OBJC_CLASS_$_RCTSRWebSocket", referenced from:
      objc-class-ref in libReact.a(RCTInspectorPackagerConnection.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Pod 文件:

target "xy" do
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'CxxBridge' # Include if RN >= 0.47
  ]
  pod 'DoubleConversion', podspec: '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'GLog', podspec: '../node_modules/react-native/third-party-podspecs/GLog.podspec'


  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'Firebase/Core'
  pod 'GoogleToolboxForMac/NSData+zlib'
  pod 'CodePush', :path => '../node_modules/react-native-code-push'
  pod 'react-native-fetch-blob', :path => '../node_modules/react-native-fetch-blob'
  pod 'RNShare', :path => '../node_modules/react-native-share'
  pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk/ios'
  pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'

end

【问题讨论】:

【参考方案1】:

您可以尝试将其添加到您的pod 'React' 部分,如下所示:

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
    'CxxBridge',
    'RCTWebSocket'
 ]

别忘了运行pod install

如果这不起作用:

打开 XCode, 点击您的项目根目录 选择你的目标 选项卡:构建阶段 将二进制文件与库链接 按+(在本节的底部)和 添加libRCTWebsocket.a

这应该可以解决它。

【讨论】:

以上是关于切换到调试时架构 x86_64 的未定义符号的主要内容,如果未能解决你的问题,请参考以下文章

Xcode 无法构建 React Native 项目,架构 x86_64 的未定义符号

编译时错误“架构 x86_64 的未定义符号”是啥意思?

架构 x86_64 的未定义符号,颤振 ios

架构 x86_64 的未定义符号将 QT 与 Opencv 结合使用

架构 x86_64 / i386 的未定义符号

Quickblox:架构 x86_64 的未定义符号:错误