React-native: Archiving react native project with cocoapods error duplicate symbols

Created on 9 Mar 2017  ·  43Comments  ·  Source: facebook/react-native

Description

Updated my project to 0.42.0. After getting everything working in simulator and device on both Debug and Release scheme, I tried to archive with and without fastlane so I can submit to app store. I expected it to work, but the archive failed with duplicate symbols.

Reproduction

Recreated from react native cli
added podfile
pod installed
attached my team on General -> Signing

https://github.com/ethantran/ReactNativeWithCocoaPods

Solution

I am aware of this issue https://github.com/facebook/react-native/issues/8534
I tried removing all libRCT*.a and libReact.a as he suggested but with no luck. Removing those will lead to errors such as RCTRawText not found. Perhaps I did not understand what he meant.

Additional Information

  • React Native version: 0.42.0
  • Platform: iOS
  • Operating System: MacOS Sierra
  • Dev tools: Xcode 8.2.1
    CocoaPods version: 1.2.0
Bug Help Wanted iOS Locked CocoaPods

Most helpful comment

For me, none of the above solutions worked so I´ll write what It worked if is helpful for anyone.
Using: RN [0.46.4] BUT initially I was with RN [0.45.1].

My Podfile has React and Yoga like (and other Pods):

  pod 'React',
    :path => "../node_modules/react-native",
    :subspecs => [
      "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "BatchedBridge"
    ]
  pod 'Yoga',
    :path => "../node_modules/react-native/ReactCommon/yoga"
  1. Open your [yourproject].xcworkspace
  2. Select your Pods project
  3. In TARGETS delete React. (clicking on the minus button - below of the targets list.)
  4. Clean (Product > Clean) & archive/build/whatever.

Hope it helps someone else!

All 43 comments

I have the exact same issue: managed to update to RN 42 so it works in both debug and release schemes on both simulator and actual device.

However, when archiving, the process fails with the following error (showing one example and the end of the log file):

duplicate symbol _OBJC_METACLASS_$_RCTWebSocketModule in:
    /Users/Jordan/Library/Developer/Xcode/DerivedData/MyApp-dzcgmvyhcbyssvbruzhemkenksex/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/libReact.a(RCTWebSocketModule.o)
    /Users/Jordan/Library/Developer/Xcode/DerivedData/MyApp-dzcgmvyhcbyssvbruzhemkenksex/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/libRCTWebSocket.a(RCTWebSocketModule.o)
ld: 287 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My investigation

Here's my Link Binary With Libraries build phase:
capture d ecran 2017-04-10 a 17 40 10

If I remove each library from this list that show as duplicate when archiving, then the Archive process succeeds.

However, if I run the app on the Sim or on a device, I get a Native module cannot be null. error that shows up:
simulator screen shot 10 avr 2017 a 17 43 20

Conclusion

It seems that:

  • when running the app on a simulator or a device, the build process is more "lazy" and allows for symbol duplication,

I find this one pretty unlikely, but I'm not an Objective-C compilation expert

OR

  • when archiving the app, the compiler is using more search paths that includes a place where these symbols are defined again (hence the duplication),

OR

  • when running the app on a simulator or a device, the compiler is not looking in the right search paths, so it needs the libraries to be separately included in the Link Binary With Libraires step.
    > Could be bypassing some pod-issued additional configuration? Would be my favorite if I had to guess which one of these is causing the issue.

Don't hesitate to correct me if I'm wrong, or if something is not properly explained. I may as well be totally off the actual issue, but I thought every input can help.

References

Podfile

platform :ios, '8.0'
inhibit_all_warnings!

source 'https://github.com/CocoaPods/Specs.git'


target 'MyApp' do
  pod 'React', :path => './node_modules/react-native', :subspecs => [
      'Core',
      'RCTImage',
      'RCTNetwork',
      'RCTText',
      'RCTWebSocket',
      'RCTSettings',
      'RCTActionSheet',
      # Add any other subspecs you want to use in your project
  ]

  pod [...]
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['DYLIB_COMPATIBILITY_VERSION'] = ''
        end
    end
end

I received the same problem and fixed it by following http://stackoverflow.com/questions/42021796/react-native-xcode-project-product-archive-fails-with-duplicate-symbols-for-arch

Like the answer says, its because of being linked through react-native's initial setup and in my case also getting linked through cocoapods as well (I just figured I would add my experience here on how I fixed it for extra reference)

Im not sure about the null part of the NativeMethods though

When I removed

pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'RCTText',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTSettings',
    'RCTVibration',
    'RCTGeolocation',
    'RCTActionSheet',
    'RCTNetwork',
    'RCTWebSocket'
  ]

from my Podfile and React 0.11.0 upon pod install.

How to deal with it keeping configuration only in one place in Podfile or XCode?

+1 on that @bitsal

I have the same issue. Is anyone able to fix this?

@vinhtq We've just removed Cocoapods from the project at all.
react-native link <lib> or/and manual linking works for us perfectly. Especially, we did it many times due to some periodic issues.

So the suggestion is to get rid of Cocoapods at all?

I have just started using it because it was recommended in some library.

I wouldn't say it is a suggestion, it is a workaround to move a project forward ;)

clovs answer in #12042 solved the issue for me..

For me, none of the above solutions worked so I´ll write what It worked if is helpful for anyone.
Using: RN [0.46.4] BUT initially I was with RN [0.45.1].

My Podfile has React and Yoga like (and other Pods):

  pod 'React',
    :path => "../node_modules/react-native",
    :subspecs => [
      "Core",
      "ART",
      "RCTActionSheet",
      "RCTAnimation",
      "RCTCameraRoll",
      "RCTGeolocation",
      "RCTImage",
      "RCTNetwork",
      "RCTText",
      "RCTVibration",
      "RCTWebSocket",
      "DevSupport",
      "BatchedBridge"
    ]
  pod 'Yoga',
    :path => "../node_modules/react-native/ReactCommon/yoga"
  1. Open your [yourproject].xcworkspace
  2. Select your Pods project
  3. In TARGETS delete React. (clicking on the minus button - below of the targets list.)
  4. Clean (Product > Clean) & archive/build/whatever.

Hope it helps someone else!

@andfk Thanks, that worked. Automated step 3 from your instruction:

package.json snippet:

"react-native": "^0.45.1",
"react-native-maps": "^0.16.0",
"react": "16.0.0-alpha.12",

Cocoapods:

pod --version
1.2.1

Final ios/Podfile configuration

# You Podfile should look similar to this file. React Native currently does not support use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'

target '<CHANGE_THIS_TO_YOUR_TARGET>'  do

  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
  pod 'React', path: '../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'BatchedBridge'
  ]

  pod 'GoogleMaps'

  pod 'react-native-maps', :path => '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => '../node_modules/react-native-maps'

end


post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "react-native-google-maps"
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end

    if target.name == "React"
      target.remove_from_project
    end
  end
end

So I get the duplicate symbols with Archive issue but also see the problem where if the react libraries are only referenced in the podfile then react-native run-ios fails to find the references. e.x. @habovh has the red error screen.

The workaround above works but shouldn't be needed. I think the react-native cli may have an issue with it's build command where the podfile references are not being linked.

@andfk Thanks bro!!!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@eugenehp @andfk Thanks guys that worked out! 👍 But do you know why removing the React Pods solves this? Or even, why should they be installed anyway when they got removed afterwards from the project. I am a bit confused.

@JPeer264 I didn't dive deep into that topic, basically on top of that hack I figured that google maps component was breaking the internal dependencies and the order of how it's compiled.
so instead of making it right, it's more of a hack for the platform.

If you find the real story behind why is it failing, please do share it here or somewhere.

Thanks.

@alloy since you commented on #8534. Note that I'm reproducing this even now at RN 0.52. I can run my app on device and simulators fine, but now when I want to archive for upload to app store, I'm getting this in Xcode:

...
duplicate symbol _OBJC_METACLASS_$_RCTWebSocketModule in:
    ~/Library/Developer/Xcode/DerivedData/WonderSwipe-coouvzgirqlxsaeaczzuypknpazb/Build/Intermediates.noindex/ArchiveIntermediates/WonderSwipe/BuildProductsPath/Release-iphoneos/libReact.a(RCTWebSocketModule.o)
    ~/Library/Developer/Xcode/DerivedData/WonderSwipe-coouvzgirqlxsaeaczzuypknpazb/Build/Intermediates.noindex/ArchiveIntermediates/WonderSwipe/BuildProductsPath/Release-iphoneos/libRCTWebSocket.a(RCTWebSocketModule.o)
ld: 262 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ react-native info

Environment:
  OS: macOS Sierra 10.12.6
  Node: 9.4.0
  Yarn: 1.3.2
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: Not Found

Packages: (wanted => installed)
  react: 16.2.0 => 16.2.0
  react-native: 0.52.0 => 0.52.0

I'm still looking at what workarounds there are with this. But since this issue is a year old, is this really persisting for this long? Is there this few people using RN and Pods that are uploading to app store?

I'm looking at removing some libs from Xcode that duplicates, but last time I tried it I ran into other errors:

screenshot 2018-01-17 07 36 56

My Podfile:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'   # 8.3 until react-native-firebase 3.2.0: Specs satisfying the `RNFirebase (from `../node_modules/react-native-firebase/ios`)` dependency were found, but they required a higher minimum deployment target.

target 'wonderswipe' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # Can't use with Firebase pod? https://github.com/invertase/react-native-firebase/issues/252#issuecomment-316340974
  # use_frameworks!

  # Pods for wonderswipe
  pod 'Firebase/Core'
  # pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'    # http://invertase.io/react-native-firebase/#/installation-ios
  # # pod 'RNFirebase', :path => '../../ios/RNFirebase.podspec'   # https://github.com/invertase/react-native-firebase/releases/tag/v3.2.0
  # pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"   # RN 0.48 and below
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'   # RN 0.49+
  # https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'BatchedBridge',  # Required For React Native 0.45.0+?
    'Core',
    'tvOS',   # WORKAROUND: https://github.com/facebook/react-native/issues/17027
    'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43    fixes https://github.com/facebook/react-native/issues/15775#issuecomment-327971300
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket', # needed for debugging
    # Add any other subspecs you want to use in your project
  ]
  # [OPTIONAL PODS] - comment out pods for firebase products you won't be using.
  # pod 'Firebase/AdMob'
  # pod 'Firebase/Crash'
  # pod 'Firebase/DynamicLinks'
  pod 'Firebase/Auth'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Database'
  pod 'Firebase/Firestore'
  pod 'Firebase/Storage'
  pod 'Firebase/Messaging'    # Need setup: http://invertase.io/react-native-firebase/#/installation-ios?id=_3-cloud-messaging-optional
  pod 'Firebase/Performance'
  # https://rnfirebase.io/docs/v3.2.*/crashlytics/ios

  # Add new pods below this line
  pod 'react-native-orientation', :path => '../node_modules/react-native-orientation'



#  target 'wonderswipe-tvOSTests' do
#    inherit! :search_paths
#    # Pods for testing
#  end
#
#  target 'wonderswipeTests' do
#    inherit! :search_paths
#    # Pods for testing
#  end

end

#target 'wonderswipe-tvOS' do
#  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
#  # use_frameworks!
#
#  # Pods for wonderswipe-tvOS
#
#  target 'wonderswipe-tvOSTests' do
#    inherit! :search_paths
#    # Pods for testing
#  end
#
#end


# WORKAROUND: https://github.com/facebook/react-native/issues/17274#issuecomment-356363557
post_install do |installer|
  installer.pods_project.targets.each do |target|
      if target.name == 'yoga'
          target.build_configurations.each do |config|
              config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
              config.build_settings['GCC_WARN_64_TO_32_BIT_CONVERSION'] = 'NO'
          end
      end
  end
end

I removed libRCTNetwork.a, libRCTWebSocket.a, libRCTText.a from being linked in Xcode. But when I run the app on device, I get this error:

*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Native module cannot be null.', reason: 'Unhandled JS Exception: Native module cannot be null., stack:

screenshot 2018-01-17 07 55 43

If you use CocoaPods to pull in React, then you should not be adding any static React libs to your project yourself, i.e. all the libRCT*.a ones.

No. libRCT*.a needs to be linked or I get https://github.com/facebook/react-native/issues/12814#issuecomment-292993002

The only working solution after trying everything is https://github.com/facebook/react-native/issues/12814#issuecomment-318922160

This trick worked for me https://stackoverflow.com/a/46678210/988941
But it's clearly weird that we have libs duplicated in YOUPROJECT/Libraries and Pods...

Anyone else getting the duplicate UUID warning from cocoapods after using the suggested workaround?

I added

if target.name == "React"
  target.remove_from_project
end

and am seeing this on pod install

[!] [Xcodeproj] Generated duplicate UUIDs:

XCBuildConfiguration -- 
XCBuildConfiguration -- 
PBXBuildFile -- 
PBXBuildFile -- 
PBXBuildFile -- 
(about 100 more lines of this)
PBXBuildFile -- 
PBXBuildFile -- 
PBXBuildFile -- 
PBXBuildFile -- 
PBXContainerItemProxy --

I tried reverting my change just to see if that was indeed what caused the warning, and after I removed it and re-installed the warnings are gone.

Got the exact same issue after adding the trick.
I didn't find a way to "fix" this warnings (except a solution that seems to ignore those and that update Podfile.lock CHECKSUM each time your do pod install which sucks a lot if your add lock file into git).

So I am looking for another solution (but didn't find anything yet...)

I can confirm what MoOx describes. I’m seeing same stuff on bunch of my
projects on top of cocoapods.

On Thu, Feb 15, 2018 at 12:25 AM MoOx notifications@github.com wrote:

Got the exact same issue after adding the trick.
I didn't find a way to "fix" this warnings (except a solution that seems
to ignore those and that update Podfile.lock CHECKSUM each time your do pod
install which sucks a lot if your add lock file into git).

So I am looking for another solution (but didn't find anything yet...)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/12814#issuecomment-365855895,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABxW7-O36bD-IB35AMhjof6XYcA0f2WXks5tU-oUgaJpZM4MXkPA
.

@stueynet at stackoverflow answer worked for me. It's basically adding the following snippets to the podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

pod install
Xcode clean build and archive

@abdulhameedalyousef that solution worked for me

That doesn't work for me. I get multiple errors of [!] [Xcodeproj] Generated duplicate UUIDs

Manually deleting React from Xcode works for me (which is obviously still tedious). There's still no proper fix after more than a year?

@fungilation, these are apparently just warnings ;)

No they are not. Build or archiving would fail

@eugenehp thanks, your answer help me.

Glad it helped.

On Tue, Sep 25, 2018 at 3:07 AM qinlan notifications@github.com wrote:

@eugenehp https://github.com/eugenehp thanks, your answer help me.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/12814#issuecomment-424282674,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABxW72qwnNoTWHwodWY3kMDHrAhAN8gyks5uegB0gaJpZM4MXkPA
.

FYI There’s a Podfile option to disable deterministic UUIDs, maybe that will help some of you:

install! 'cocoapods', :deterministic_uuids => false

Hi! This might be caused by the fact that you have libReact.a and libPods.a with React pod both linked to your project. You should decide which one to choose, the mixed approach with @khiami 's workaround might lead to multiple issues.

If you still experience this issue, please check your local setup, and check if you're using the newest version of XCode / CocoaPods / React Native.

If the issue still persist please comment below and we can reopen it 😁

its always always always (usually) straight up bc somehow somewhere youre
including it twice im tellin u what....

rofl

gl

God bless

On Tue, Mar 19, 2019 at 9:30 AM Michał Chudziak notifications@github.com
wrote:

Closed #12814 https://github.com/facebook/react-native/issues/12814.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/12814#event-2213781065,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AO-zkV59-cAaFNIVNT-HmWisvNl2FoSDks5vYPSYgaJpZM4MXkPA
.

Two years later...

same issue on RN 0.59

same issue on RN 0.59.3

59.10

0.60.0

Same here on 0.60.0

Same here.......

After installing Xcode 11 I've got the same issue. Nice.

Same here on 0.60.5

Was this page helpful?
0 / 5 - 0 ratings