【问题标题】:react-native-svg undefined symbols dylib when compiling on iOS在 iOS 上编译时 react-native-svg 未定义符号 dylib
【发布时间】:2022-07-08 05:13:19
【问题描述】:

我正在尝试在 iOS 上编译一个 React Native 应用程序。

我经常遇到与链接器相关的错误,基本上是说dylib 报告有未定义的符号,这些符号与链接到项目的一些pod 模块有关。

就我而言,react-native-svg 有问题

安装包并编译:

$ npm install --save react-native-svg
$ npx pod-install  # or cd ios && pod install && cd ..
$ npx react-native link react-native-svg
$ open ios/<project-name>.xcworkspace &
$ # then compile the react-native project in iOS

所以:

  • 软件包已安装
  • Podfile 已安装
  • 包已链接

有时在为模拟器 (x86_64) 编译时会发生这种情况,有时在为我的设备 (arm64) 编译时会发生这种情况。它随机出现,但我没有解决问题。有时它在重新启动后可以工作,有时不能。有时它在清理构建文件夹后可以工作,有时不能。有时它在重新启动 Xcode 后可以工作,有时不能。有时它在重新运行pod install 并重新链接工作后工作,有时不工作。似乎没有什么能始终如一地工作。

任何见解都将不胜感激。

错误如下

Ld /Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/RNSVG/RNSVG.framework/RNSVG normal (in target 'RNSVG' from project 'Pods')
    cd /Users/adonis/sandbox/my-projects/github/pktwallet-mobile/ios-tests/pktwallet/ios/Pods
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios9.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.2.sdk -L/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/RNSVG -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/RNSVG -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/DoubleConversion -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/FBReactNativeSpec -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/RCT-Folly -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/RCTTypeSafety -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-Core -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTAnimation -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTBlob -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTImage -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTLinking -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTNetwork -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTSettings -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTText -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-RCTVibration -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-cxxreact -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-jsi -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-jsiexecutor -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-jsinspector -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/React-perflogger -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/ReactCommon -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/Yoga -F/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/glog -filelist /Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/RNSVG.build/Objects-normal/arm64/RNSVG.LinkFileList -install_name @rpath/RNSVG.framework/RNSVG -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/RNSVG.build/Objects-normal/arm64/RNSVG_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -fobjc-arc -fobjc-link-runtime -framework Foundation -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/RNSVG.build/Objects-normal/arm64/RNSVG_dependency_info.dat -o /Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/RNSVG/RNSVG.framework/RNSVG

ld: warning: dylib (/Users/adonis/Library/Developer/Xcode/DerivedData/pktwallet-cuihgpnujfgpvbcdatertduvqenu/Build/Products/Debug-iphoneos/Yoga/yoga.framework/yoga) was built for newer iOS version (10.0) than being linked (9.0)
Undefined symbols for architecture arm64:
  "__RCTNotImplementedException", referenced from:
      -[RNSVGPainter init] in RNSVGPainter.o
  "_OBJC_CLASS_$_RCTFont", referenced from:
      objc-class-ref in RNSVGGlyphContext.o
  "_OBJC_METACLASS_$_RCTViewManager", referenced from:
      _OBJC_METACLASS_$_RNSVGDefsManager in RNSVGDefsManager.o
      _OBJC_METACLASS_$_RNSVGNodeManager in RNSVGNodeManager.o
      _OBJC_METACLASS_$_RNSVGSvgViewManager in RNSVGSvgViewManager.o
  "_OBJC_CLASS_$_RCTViewManager", referenced from:
      _OBJC_CLASS_$_RNSVGDefsManager in RNSVGDefsManager.o
      _OBJC_CLASS_$_RNSVGNodeManager in RNSVGNodeManager.o
      _OBJC_CLASS_$_RNSVGSvgViewManager in RNSVGSvgViewManager.o
  "_RCTConvertEnumValue", referenced from:
      +[RCTConvert(RNSVG) RNSVGCGFCRule:] in RCTConvert+RNSVG.o
      +[RCTConvert(RNSVG) RNSVGVBMOS:] in RCTConvert+RNSVG.o
      +[RCTConvert(RNSVG) RNSVGUnits:] in RCTConvert+RNSVG.o
  "__RCTLogNativeInternal", referenced from:
      +[RCTConvert(RNSVG) RNSVGBrush:] in RCTConvert+RNSVG.o
      +[RCTConvert(RNSVG) RNSVGCGRect:offset:] in RCTConvert+RNSVG.o
      +[RCTConvert(RNSVG) RNSVGCGColor:offset:] in RCTConvert+RNSVG.o
      -[RNSVGNode svgView] in RNSVGNode.o
      +[RNSVGNodeManager CATransform3DFromMatrix:] in RNSVGNodeManager.o
      +[RNSVGNodeManager CATransform3D:] in RNSVGNodeManager.o
      -[RNSVGPainter paintLinearGradient:bounds:] in RNSVGPainter.o
      ...
  "_RCTExecuteOnUIManagerQueue", referenced from:
      ___58-[RNSVGSvgViewManager toDataURL:options:callback:attempt:]_block_invoke in RNSVGSvgViewManager.o
  "_RCTRegisterModule", referenced from:
      +[RNSVGCircleManager load] in RNSVGCircleManager.o
      +[RNSVGClipPathManager load] in RNSVGClipPathManager.o
      +[RNSVGDefsManager load] in RNSVGDefsManager.o
      +[RNSVGEllipseManager load] in RNSVGEllipseManager.o
      +[RNSVGForeignObjectManager load] in RNSVGForeignObjectManager.o
      +[RNSVGGroupManager load] in RNSVGGroupManager.o
      +[RNSVGImageManager load] in RNSVGImageManager.o
      ...
  "_OBJC_CLASS_$_RCTConvert", referenced from:
      __OBJC_$_CATEGORY_RCTConvert_$_RNSVG in RCTConvert+RNSVG.o
      objc-class-ref in RNSVGForeignObjectManager.o
      objc-class-ref in RNSVGImage.o
      objc-class-ref in RNSVGImageManager.o
      objc-class-ref in RNSVGMaskManager.o
      objc-class-ref in RNSVGNodeManager.o
      objc-class-ref in RNSVGPainter.o
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

【问题讨论】:

    标签: ios xcode react-native react-native-svg


    【解决方案1】:

    似乎解决方案是转到我的 Pod 并升级 Deployment Target 版本

    【讨论】:

      【解决方案2】:

      我建议你重新安装到这个包的最新版本。

      如果您使用的是 RN >= 0.60,请执行此命令:

      $ yarn remove react-native-svg
      
      $ react-native unlink react-native-svg
      
      $ yarn add react-native-svg
      
      $ cd ios && pod install
      

      【讨论】:

        猜你喜欢
        • 2013-03-07
        • 1970-01-01
        • 2021-11-29
        • 2015-05-23
        • 2016-11-18
        • 1970-01-01
        • 1970-01-01
        • 2018-01-14
        相关资源
        最近更新 更多