Skip to content

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

Open

Description

@jonathanschad

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

Activity

  1. soring323 commented on Feb 8, 2022

    @soring323

    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.

  2. Florent75 commented on Mar 7, 2022

    @Florent75

    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

  3. Rc85 commented on Sep 7, 2022

    @Rc85

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

  4. chachaxw commented on Sep 29, 2022

    @chachaxw

    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🤩

  5. nriccar commented on Jul 12, 2023

    @nriccar

    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?

  6. Kailash23 commented on Apr 24, 2024

    @Kailash23

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions