React Native 中架构 x86_64 的 7 个重复符号

当我尝试在 ios 模拟器上运行我的 react 本机应用程序时,我收到了这个错误。

错误:

duplicate symbol '_EXCanAskAgain' in:
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/EXPermissions/libEXPermissions.a(EXPermissions.o)
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/UMReactNativeAdapter/UMReactNativeAdapter.framework/UMReactNativeAdapter(EXPermissionsService.o)
duplicate symbol '_EXExpiresKey' in:
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/EXPermissions/libEXPermissions.a(EXPermissions.o)
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/UMReactNativeAdapter/UMReactNativeAdapter.framework/UMReactNativeAdapter(EXPermissionsService.o)
duplicate symbol '_EXGrantedKey' in:
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/EXPermissions/libEXPermissions.a(EXPermissions.o)
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/UMReactNativeAdapter/UMReactNativeAdapter.framework/UMReactNativeAdapter(EXPermissionsService.o)
duplicate symbol '_EXPermissionExpiresNever' in:
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/EXPermissions/libEXPermissions.a(EXPermissions.o)
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/UMReactNativeAdapter/UMReactNativeAdapter.framework/UMReactNativeAdapter(EXPermissionsService.o)
duplicate symbol '_EXStatusKey' in:
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/EXPermissions/libEXPermissions.a(EXPermissions.o)
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/UMReactNativeAdapter/UMReactNativeAdapter.framework/UMReactNativeAdapter(EXPermissionsService.o)
duplicate symbol '_OBJC_CLASS_$_EXReactNativeUserNotificationCenterProxy' in:
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/EXPermissions/libEXPermissions.a(EXReactNativeUserNotificationCenterProxy.o)
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/UMReactNativeAdapter/UMReactNativeAdapter.framework/UMReactNativeAdapter(EXReactNativeUserNotificationCenterProxy.o)
duplicate symbol '_OBJC_METACLASS_$_EXReactNativeUserNotificationCenterProxy' in:
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/EXPermissions/libEXPermissions.a(EXReactNativeUserNotificationCenterProxy.o)
    /Users/harshmishra/Library/Developer/Xcode/DerivedData/myways-gkjarpvjrufpitdstvqcnasxhmrs/Build/Products/Debug-iphonesimulator/XCFrameworkIntermediates/UMReactNativeAdapter/UMReactNativeAdapter.framework/UMReactNativeAdapter(EXReactNativeUserNotificationCenterProxy.o)
ld: 7 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我尝试清理构建文件夹,再次运行 pod install 但没有任何效果。我被困在这个错误上。我无法找到导致此错误的原因。另外,我检查了 myApp > Libraries 文件夹,没有任何内容(空文件夹)。

stack overflow 7 duplicate symbols for architecture x86_64 in react native
原文答案

答案:

作者头像

将 react-native-unimodules 库添加到我正在开发的应用程序后,我遇到了完全相同的错误。

经过几个小时尝试不同的解决方案,我们能够通过将 react-native-unimodules 库从当前的 0.14.7 版本降级到 0.13.3 来修复错误。

  • 更改 package.json 中的 react-native-unimodules 版本
  • 重新安装包(yarn install for me)
  • cd ios,然后 pod deintegrate(只是为了确定),然后 pod install
  • 在 XCode 中转到产品选项卡并从那里清理构建文件夹
  • 启动应用程序并成功编译

希望它可以帮助遇到该问题的其他人。

作者头像

react-native-unimodules 库 0.14.7 中的 expo-permissions 已过时,导致构建应用程序时架构 x86_64 的 7 个重复符号在 react native 问题中。要解决此问题,您需要

  • 运行 npm install expo-permissions
  • ios 文件夹中运行 pod install
  • 再次构建并运行 iOS 应用程序
作者头像

已解决 @2022 年 1 月 20 日

react-native-unimodules 是罪魁祸首。因为 expo 已经更新了自己,并且 react-native-unimodules 现在已被弃用。

yarn remove react-native-unimodules

或者

npm uninstall react-native-unimodules

在 pod 文件中

# require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
# use_unimodules!

还要清理你的 AppDelegate.m 和 AppDelegate.h

删除节点模块

    pod install

进行构建,一切顺利。世博包将不起作用。现在再次从 package.json 中删除您当前正在使用的 expo 包 yarn install 然后在 iOS 目录中 pod install 并使构建一切正常。仍然 expo 包不起作用,现在搜索您要使用的任何 expo-package,然后按照文档进行操作。稍后谢谢我。

作者头像

尝试将 expo-permissions 升级到最新版本

相关问题