facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.2k stars 24.1k forks source link

ld: 1319 duplicate symbols for architecture x86_64 after upgrading to 0.60 from 0.59.9 #25484

Closed roshangm1 closed 5 years ago

roshangm1 commented 5 years ago

I upgraded the react native version to 0.60 from 0.59.9. I wasn't using any Pods when on 0.59.9. But after 0.60, I added Podfile with following content (as per rn-diff)

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'taxiApp' do
rn_maps_path = '../node_modules/react-native-maps'
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'taxiAppTests' do
    inherit! :search_paths
    # Pods for testing
  end
  use_native_modules!
end 

//this is for solving some issue with react-native-config and cocoapods
post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'react-native-config'
        phase = target.project.new(Xcodeproj::Project::Object::PBXShellScriptBuildPhase)
        phase.shell_script = "cd ../../"\
                             " && RNC_ROOT=./node_modules/react-native-config/"\
                             " && export SYMROOT=$RNC_ROOT/ios/ReactNativeConfig"\
                             " && export BUILD_DIR=$RNC_ROOT/ios/ReactNativeConfig"\
                             " && ruby $RNC_ROOT/ios/ReactNativeConfig/BuildDotenvConfig.ruby"

        target.build_phases << phase
        target.build_phases.move(phase,0)
      end
    end
  end

I did pod install which installed 4 extra pods (maybe as a part of auto linking):

react-native-config (0.11.7)
react-native-geolocation (1.4.2)
react-native-maps (0.24.2)
RNGestureHandler

After that, I opened Xcode and started building the app and I got this issue with duplicate symbols. A lot of pods/libraries are being installed (duplicate). For example:

I think this is a problem Both jsi and React-jsi are being installed while building the project.

React Native version:

System:
    OS: macOS 10.14.5
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 89.96 MB / 8.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 11.9.0 - /usr/local/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.5.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 27.0.3, 28.0.3
      System Images: android-24 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.0 => 0.60.0
  npmGlobalPackages:
    react-native-cli: 2.0.1
    react-native-git-upgrade: 0.2.7

Steps To Reproduce

  1. Upgrade to RN-0.60
  2. Have packages which needs installing pods
  3. pod install
  4. Build the project from XCode

Describe what you expected to happen: I expect it to not install duplicate pods/libraries and successful build.

roshangm1 commented 5 years ago

Link Binary and Libraries in Build Phases looks like this.

image
roshangm1 commented 5 years ago

I actually removed all of these contents inside Link Binary With Libraries and the build was successful. But I don't understand what's going on in here.

Kida007 commented 5 years ago

I think RN shifted to Pods , all native ios stuff is now handled by pods , Therefore you don't need those Linked Libraries. https://github.com/react-native-community/upgrade-helper/issues/47

I updated from 0.57.8 to 0.60.0 following RN Update Helper and my build still failing :(

roshangm1 commented 5 years ago

Closing this because I think removing these contents from Link Binary With Binaries is a required move.

stefansukara commented 5 years ago

Just remove everything from Build Phases/ Link Binary With Libraries , and it must work! 🤙🤘

Psiiirus commented 5 years ago

Just a little hint if you use PushNotifications you have to extend the Podfile on your own! ...took me a while to noticed this

martindavid commented 5 years ago

@Psiiirus Can you enlight us with this? Because I'm having the same issue with PushNotification as well after upgrade to 0.60.0

Psiiirus commented 5 years ago

@Psiiirus Can you enlight us with this? Because I'm having the same issue with PushNotification as well after upgrade to 0.60.0

i created a pull request to change the docs , i hope this can help you for now? https://deploy-preview-1087--react-native.netlify.com/docs/next/pushnotificationios

PavanKumar-sa commented 5 years ago

@Psiiirus Facing issue with PushNotificationIOS after upgrading to 0.60, can you let us know how RCTPushNotification is listed in pod file.

Below is the error details:

In file included from /../node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m:8:

/../node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h:8:9: fatal error: 'React/RCTEventEmitter.h' file not found

import <React/RCTEventEmitter.h>

^~~~~~~~~

@martindavid Did u get the fix for the PushNotification?

Psiiirus commented 5 years ago

@Psiiirus Facing issue with PushNotificationIOS after upgrading to 0.60, can you let us know how RCTPushNotification is listed in pod file.

Below is the error details:

In file included from /../node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m:8:

/../node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h:8:9: fatal error: 'React/RCTEventEmitter.h' file not found

import <React/RCTEventEmitter.h>

^~~~~~~~~

@martindavid Did u get the fix for the PushNotification?

Not 100% whats your problem is, sorry....but one lession i learned...drop the whole node_modules folder and do a clean build :)

OlegNovosad commented 4 years ago

rm -rf Podfile.lock pod deintegrate pod install

Remove if something left in Link Binaries.

gudbrand3 commented 4 years ago

THANK YOU @ roshangm1 !!

This worked like a charm, took me forever to find this thread though. Had the same issue on react-native 0.60.5

jhainaua commented 4 years ago

I did this and the project builds; however, I'm now getting the following:

Screen Shot 2019-08-21 at 5 21 12 PM

Any idea what I did wrong/how to fix?

erick4556 commented 4 years ago

Hi @Kida007 , how did you update to react-native 0.60 ? I have a few issues when I making that update

Kida007 commented 4 years ago

Using update helper .

zvone00 commented 4 years ago

To make this work, I had to entirely remove content from Library folder, not just unlink dependencies.

khuramdogar commented 4 years ago

If you are using a Podfile you can also remove React-RCTPushNotification and add the following...

pod 'RNCPushNotificationIOS', :path => '../node_modules/@react-native-community/push-notification-ios' because React-RCTPushNotification is from 'react-native' but push notifications has been moved to @react-native-community.