React Native iOS - 架构x86_64未定义符号

17
我已经开发了一款React Native应用程序,在Android上运行良好......但是当我尝试在iOS上构建时,出现以下错误:Undefined symbols for architecture x86_64 看起来这与Flipper有关,因为详细的错误如下所示:
     link with file built for iOS Simulator-arm64
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_FlipperKitNetworkPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FlipperKitReactPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_SKDescriptorMapper", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FlipperClient", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RNCPushNotificationIOS", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FlipperKitLayoutPlugin", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTRootView", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTBridge", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_SKIOSNetworkAdapter", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_RCTBundleURLProvider", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FBSDKApplicationDelegate", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_FKUserDefaultsPlugin", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
1个回答

56

我在m1上也遇到了同样的问题,做了以下操作后解决了:

修改构建设置 -> 排除架构选项,添加任何iOS模拟器SDK选项,并将值设置为arm64。如图所示:

enter image description here

然后在Podfile中添加以下代码:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
    end
  end
end

我爱你!非常感谢你。 - Mateo Verdaguer
1
谢谢! 更改Podfile就解决了问题-不需要进行Xcode更改部分。 - MasterPiece
1
我不明白这个问题 - 我使用的是M1芯片的Mac,所以我的模拟器在运行arm64架构,对吗?为什么要排除该架构呢?顺便问一下,为什么还要构建任何基于x86_64的内容呢? - iameli
2
创建静态库时,将为实际设备(arm64)和模拟器(x86_64)分别打包版本。在英特尔 Mac 上,模拟器使用 x86_64 指令没有问题,但在 M1 Mac 上会出现问题。在排除 arm64 架构后,模拟器仍然以 arm64 模式运行,但模拟器中的应用程序以 x86 模式运行。https://juejin.cn/post/7037037120158269448 - Z Hu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接