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

问题描述 投票:0回答:1

所以标题说,我试过两个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本身
  • 添加对podfile的修改,如下所示: # 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
  • 尝试使用RCTCxxBridgeCxxBridge而不是BatchedBridge,因为它被认为已被弃用

但仍然没有运气......任何指针都会在这里受到赞赏:)

ios xcode reactjs react-native build
1个回答
1
投票

因此,根据评论,显然这是以前失败的构建缓存,这会搞乱我的归档过程。我所要做的就是删除node_modulesios/buildsios/Pods然后再次做npm installreact-native linkcd ios && pod install,项目一切都很好。

之后我得到duplicate symbols on arm64错误,这只是因为react-nativeRCTWebSocket都有一些重叠的类。所以要解决这个问题,我只需要从XCode的General选项卡上的Project的libRCTWebSocket.a info子类别中删除Linked Frameworks and Libraries

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

© www.soinside.com 2019 - 2024. All rights reserved.