iOS Build is failing (duplicate symbols for architecture x86_64)
Opened this issue · 6 comments
This issue should serve as a starting point for others who have the same problem. I hope I can save you from a lot of headache. Original Issue: Rapsssito/react-native-tcp-socket#61 (comment)
Steps to reproduce
The issue appears if you try to compile a react native project for iOS, which uses rn-nodefiy. To be more specific the cause of the problem seems to come from react-native-tcp and react-native-udp.
It seems that it also does not matter if you use a new M1 Mac or an older Intel based Mac. Also it does not matter if you use npm or yarn
- Create a new react native project
npx react-native init AwesomeTSProject --template react-native-template-typescript
At this point your iOS version should still build correctly.
-
install rn-nodeify.
npx rn-nodeify --install --hack
-
install pods
cd ios & pod install
-
Try to build the project for iOS again
npm run ios
Your build will fail with the message ld: {number} duplicate symbols for architecture x86_64
How to solve it
Credit to @Jiope
- Go to xcode
- into project navigator, click on Pods folder
- then select TcpSockets in targets
- Go to Build Phases > Compile sources
- Here remove reference to CocoaAsyncSocket (this should be the first entry in the list)
in this case you also need to do the same for react-native-udp
It seems like you need to redo this procedure every time you add new dependencies to your project
Credit to @Jiope
Go to xcode
into project navigator, click on Pods folder
then select TcpSockets in targets
Go to Build Phases > Compile sources
Here remove reference to CocoaAsyncSocket (this should be the first entry in the list)
in this case you also need to do the same for react-native-udp
this is correct solution.
Hi there,
I just tried to install this package and I do have the same issue.
Here is part of the error logs :
duplicate symbol 'OBJC_IVAR$_GCDAsyncUdpSocket.cachedLocalPort4' in:
/Users/florent/Library/Developer/Xcode/DerivedData/Hermes-dxhzvnkbnyrabocodwsqwfpatpub/Build/Products/Debug-iphonesimulator/CocoaAsyncSocket/libCocoaAsyncSocket.a(GCDAsyncUdpSocket.o)
/Users/florent/Desktop/Bocoloco/git_florent_reactnative/HermesNative/florent_reactnative_hermes/node_modules/react-native-thermal-receipt-printer/ios/PrinterSDK/libPrinterSDK.a(GCDAsyncUdpSocket.o)
duplicate symbol 'OBJC_IVAR$_GCDAsyncUdpSocket.cachedLocalAddress4' in:
/Users/florent/Library/Developer/Xcode/DerivedData/Hermes-dxhzvnkbnyrabocodwsqwfpatpub/Build/Products/Debug-iphonesimulator/CocoaAsyncSocket/libCocoaAsyncSocket.a(GCDAsyncUdpSocket.o)
/Users/florent/Desktop/Bocoloco/git_florent_reactnative/HermesNative/florent_reactnative_hermes/node_modules/react-native-thermal-receipt-printer/ios/PrinterSDK/libPrinterSDK.a(GCDAsyncUdpSocket.o)
duplicate symbol 'OBJC_IVAR$_GCDAsyncUdpSocket.writeStream4' in:
/Users/florent/Library/Developer/Xcode/DerivedData/Hermes-dxhzvnkbnyrabocodwsqwfpatpub/Build/Products/Debug-iphonesimulator/CocoaAsyncSocket/libCocoaAsyncSocket.a(GCDAsyncUdpSocket.o)
/Users/florent/Desktop/Bocoloco/git_florent_reactnative/HermesNative/florent_reactnative_hermes/node_modules/react-native-thermal-receipt-printer/ios/PrinterSDK/libPrinterSDK.a(GCDAsyncUdpSocket.o)
duplicate symbol 'OBJC_IVAR$_GCDAsyncUdpSocket.readStream4' in:
/Users/florent/Library/Developer/Xcode/DerivedData/Hermes-dxhzvnkbnyrabocodwsqwfpatpub/Build/Products/Debug-iphonesimulator/CocoaAsyncSocket/libCocoaAsyncSocket.a(GCDAsyncUdpSocket.o)
/Users/florent/Desktop/Bocoloco/git_florent_reactnative/HermesNative/florent_reactnative_hermes/node_modules/react-native-thermal-receipt-printer/ios/PrinterSDK/libPrinterSDK.a(GCDAsyncUdpSocket.o)
ld: 137 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It seems to have some kind if conflict with the react-native-thermal-receipt-printer module.
When I check on the Pods targe / react-native-tcp-sockets / compile sources , there is nothing like CocoaAsyncSocket, but I can found it in the dependency.
Do you have any clues on how o fix it ?
Regards
@Florent75 There is a troubleshoot section in the docs about removing Flipper. If you are still having that issue after commenting out all the flipper reference in your Podfile and AppDelegate.m, then you mostly likely still have Flipper in your Pods folder. Run pod deintegrate and pod install.
Credit to @Jiope
Go to xcode into project navigator, click on Pods folder then select TcpSockets in targets Go to Build Phases > Compile sources Here remove reference to CocoaAsyncSocket (this should be the first entry in the list) in this case you also need to do the same for react-native-udp
this is correct solution.
It works for me, amazing🤩
Any way of doing this promatically from podfile or a patch-package so that we don't have to manually remove CocoaAsyncSocket after each pod install?
Any way of doing this promatically from podfile or a patch-package so that we don't have to manually remove CocoaAsyncSocket after each pod install?
Facing the same issue
CocoaAsyncSocket compile source keep adding again after pod install