切换到Debug时,体系结构x86_64的未定义符号

时间:2017-11-30 20:59:35

标签: ios xcode react-native cocoapods

当我将方案切换到Debug时,出现以下错误。在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 个答案:

答案 0 :(得分:0)

您可以尝试将其添加到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

这应该解决它。