代码之家  ›  专栏  ›  技术社区  ›  Ray Jonathan

React Native:在XCode 9.2、9.4和RN 55.4上构建IOS失败

  •  0
  • Ray Jonathan  · 技术社区  · 6 年前

    所以正如标题所说,我尝试了两个Xcode版本,但仍然没有成功。 这就是我得到的错误:

    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
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    • 遵循这些建议 here
    • 重新启动XCode和mac本身
    • # Uncomment the next line to define a global platform for your project
       platform :ios, '9.0'
      
      target 'Absent' do
        # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
        # use_frameworks!
      
        # Pods for Absent
          pod 'Firebase/Core', '~> 5.3.0'
          pod 'Firebase/Messaging', '~> 5.3.0'
          pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/'
          pod 'React', path: '../node_modules/react-native', :subspecs => [
          'RCTGeolocation',
          'RCTNetwork',
          'Core',
          'DevSupport',
          'BatchedBridge',
          'RCTAnimation',
          'RCTText',
          'RCTWebSocket'
          ]
      
        target 'AbsentTests' do
          inherit! :search_paths
          # Pods for testing
        end
      
      end
      
      target 'Absent-tvOS' do
        # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
        # use_frameworks!
      
        # Pods for Absent-tvOS
      
        target 'Absent-tvOSTests' do
          inherit! :search_paths
          # Pods for testing
        end
      
      end
      
      post_install do |installer|
       installer.pods_project.targets.each do |target|
          if target.name == "React"
               target.remove_from_project
           end
       end
      end
      
    • 尝试使用 RCTCxxBridge CxxBridge 而不是BatchedBridge,因为它应该被弃用了

    但还是没有运气。。。 如有任何提示,请点击此处:)

    1 回复  |  直到 6 年前
        1
  •  1
  •   Ray Jonathan    6 年前

    node_modules , ios/builds ios/Pods 那就做吧 npm install react-native link cd ios && pod install 又一次,整个项目都很好。

    duplicate symbols on arm64 错误仅仅是因为 react-native RCTWebSocket 有一些重叠的课程。 为了解决这个问题,我只需要删除 libRCTWebSocket.a 从项目的 Linked Frameworks and Libraries

    特别感谢@needsleep提供的解决方案!