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

Archiving react native project with cocoapods error duplicate symbols #12814

Closed
ethantran opened this issue Mar 9, 2017 · 43 comments
Closed
Labels
Bug Help Wanted :octocat: Issues ideal for external contributors. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot. Tool: CocoaPods

Comments

@ethantran
Copy link

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 #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
@habovh
Copy link
Contributor

habovh commented Apr 10, 2017

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

@cotyembry
Copy link

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

@bitsal
Copy link

bitsal commented May 5, 2017

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?

@cotyembry
Copy link

+1 on that @bitsal

@vinhtq
Copy link

vinhtq commented May 12, 2017

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

@bitsal
Copy link

bitsal commented May 12, 2017

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

@baba43
Copy link

baba43 commented Jun 1, 2017

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

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

@bitsal
Copy link

bitsal commented Jun 1, 2017

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

@sarath263
Copy link

sarath263 commented Jun 9, 2017

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

@andfk
Copy link

andfk commented Jul 30, 2017

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!

@eugenehp
Copy link

eugenehp commented Aug 12, 2017

@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

@jacksontbryan
Copy link

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.

@91debug
Copy link

91debug commented Oct 19, 2017

@andfk Thanks bro!!!

@stale
Copy link

stale bot commented Dec 18, 2017

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 18, 2017
@JPeer264
Copy link

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

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 19, 2017
@eugenehp
Copy link

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

@fungilation
Copy link

fungilation commented Jan 17, 2018

@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

@fungilation
Copy link

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

@alloy
Copy link
Contributor

alloy commented Jan 23, 2018

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.

@fungilation
Copy link

No. libRCT*.a needs to be linked or I get #12814 (comment)

The only working solution after trying everything is #12814 (comment)

@MoOx
Copy link
Contributor

MoOx commented Feb 14, 2018

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

@willbattel
Copy link

willbattel commented Feb 15, 2018

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.

@MoOx
Copy link
Contributor

MoOx commented Feb 15, 2018

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

@eugenehp
Copy link

eugenehp commented Feb 15, 2018 via email

@react-native-bot react-native-bot added Platform: iOS iOS applications. Help Wanted :octocat: Issues ideal for external contributors. labels Mar 9, 2018
@khiami
Copy link

khiami commented May 24, 2018

@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

@zesk8
Copy link

zesk8 commented May 30, 2018

@abdulhameedalyousef that solution worked for me

@fungilation
Copy link

fungilation commented May 31, 2018

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?

@GoMino
Copy link

GoMino commented Jun 30, 2018

@fungilation, these are apparently just warnings ;)

@fungilation
Copy link

No they are not. Build or archiving would fail

@438198602
Copy link

@eugenehp thanks, your answer help me.

@eugenehp
Copy link

eugenehp commented Sep 25, 2018 via email

@alloy
Copy link
Contributor

alloy commented Sep 26, 2018

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

install! 'cocoapods', :deterministic_uuids => false

@michalchudziak
Copy link
Contributor

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 😁

@cotyembry
Copy link

cotyembry commented Mar 21, 2019 via email

@TrustDec
Copy link

TrustDec commented Apr 9, 2019

Two years later...

@iacocesar
Copy link

same issue on RN 0.59

@blissktn
Copy link

same issue on RN 0.59.3

@thesergiomiguel
Copy link

59.10

@xuyendo1510
Copy link

0.60.0

@luiseduardobrito
Copy link

Same here on 0.60.0

@fendorio
Copy link

Same here.......

@ts-ign0re
Copy link

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

@gtsbgogss
Copy link

Same here on 0.60.5

@facebook facebook locked as resolved and limited conversation to collaborators Mar 20, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Help Wanted :octocat: Issues ideal for external contributors. Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot. Tool: CocoaPods
Projects
None yet
Development

No branches or pull requests