Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Build is failing (duplicate symbols for architecture x86_64) #114

Open
jonathanschad opened this issue Feb 4, 2022 · 6 comments
Open

Comments

@jonathanschad
Copy link

jonathanschad commented Feb 4, 2022

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

  1. 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.

  1. install rn-nodeify.
    npx rn-nodeify --install --hack

  2. install pods
    cd ios & pod install

  3. 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

  1. Go to xcode
  2. into project navigator, click on Pods folder
  3. then select TcpSockets in targets
  4. Go to Build Phases > Compile sources
  5. 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

@soring323
Copy link

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.

@Florent75
Copy link

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

@Rc85
Copy link

Rc85 commented Sep 7, 2022

@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.

@chachaxw
Copy link

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🤩

@nriccar
Copy link

nriccar commented Jul 12, 2023

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?

@Kailash23
Copy link

Kailash23 commented Apr 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants