I’m trying to compile a React Native app on iOS.
Many times I encounter an error related to the linker, which essentially says that dylib
reports there are undefined symbols, which are related to some pod
modules linked to the project.
In my case I’m having trouble with react-native-svg
To install the package and compile:
$ 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
So:
- Package is installed
- Podfiles are installed
- Package is linked
Sometimes this happens when compiling for simulator (x86_64) and sometimes it happens when compiling for my device (arm64). It appears randomly, but nothing I do solves the problem. Sometimes it works after a reboot, sometimes not. Sometimes it works after cleaning the build folder , sometimes not. Sometimes it works after restarting Xcode, sometimes not. Sometimes it works after re-running pod install
and re-linking works, sometimes not. Nothing appears to work consistently.
Any insight would be appreciated.
The errors are as follows
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)
2
Answers
It seems like the solution was to go to my Pods and to upgrade the Deployment Target version.
I was with the exact same error here after added
use_frameworks!
in my Podfile, I suggest you reinstall to the newest version of this package, only this resolved for me.execute this commands if you are using RN >= 0.60: