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

React pod has been deprecated and build fails #414

Closed
samuela opened this issue Sep 16, 2017 · 27 comments
Closed

React pod has been deprecated and build fails #414

samuela opened this issue Sep 16, 2017 · 27 comments

Comments

@samuela
Copy link

samuela commented Sep 16, 2017

Issue

The React pod, which is one of RNFirebase's dependencies, has been deprecated. A minimal Podfile looks something like

platform :ios, '9.0'

target 'ReactNativePlayground' do
  pod 'Firebase/Core'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
end

and running pod update && pod install, produces a warning

[!] React has been deprecated

Environment

  1. Application Target Platform: iOS
  1. Development Operating System: macOS 10.12.6
  1. Build Tools: N/A
  1. React Native version: 0.48.3
  1. RNFirebase Version: 2.2.0
  1. Firebase Module: N/A
@samuela
Copy link
Author

samuela commented Sep 16, 2017

Addendum: this causes builds to fail with RN 0.48.3, RNFirebase 2.2.0, and pods:

  - React (0.11.0):
    - React/Core (= 0.11.0)
  - React/Core (0.11.0)

The react native packager produces

This warning is caused by a @providesModule declaration with the same name across two different files.
jest-haste-map: @providesModule naming collision:
  Duplicate module name: Object.es6
  Paths: /Users/samuelainsworth/Development/ReactNativePlayground/ios/Pods/React/packager/react-packager/src/DependencyResolver/polyfills/polyfills.js collides with /Users/samuelainsworth/Development/ReactNativePlayground/node_modules/react-native/Libraries/polyfills/Object.es6.js

This warning is caused by a @providesModule declaration with the same name across two different files.
jest-haste-map: @providesModule naming collision:
  Duplicate module name: react-native
  Paths: /Users/samuelainsworth/Development/ReactNativePlayground/ios/Pods/React/package.json collides with /Users/samuelainsworth/Development/ReactNativePlayground/node_modules/react-native/package.json

.......

This warning is caused by a @providesModule declaration with the same name across two different files.
Bundling `index.ios.js`  [development, non-minified, hmr disabled]  0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `/Users/samuelainsworth/Development/ReactNativePlayground/index.ios.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them: 

  * `/Users/samuelainsworth/Development/ReactNativePlayground/ios/Pods/React/package.json`
  * `/Users/samuelainsworth/Development/ReactNativePlayground/node_modules/react-native/package.json`

I'm confident that this issue is tied to the deprecation of the React pod, etc. but I cannot be entirely certain, and others' insights here would of course be appreciated.

@samuela samuela changed the title React pod has been deprecated React pod has been deprecated and build fails Sep 16, 2017
@samuela
Copy link
Author

samuela commented Sep 16, 2017

Ah, so the pod deprecation warning is because I am a fool and forgot the

pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
pod 'React', :path => '../node_modules/react-native', :subspecs => [
  'BatchedBridge', # Required For React Native 0.45.0+
  'Core',
  # Add any other subspecs you want to use in your project
]

section in my Podfile. However, the ambiguous resolution errors persist.

@samuela
Copy link
Author

samuela commented Sep 16, 2017

Further edit: I was having build issues, but I was able to resolve them by adding DevSupport to the subspecs list for React:

pod 'React', :path => '../node_modules/react-native', :subspecs => [
  'BatchedBridge', # Required For React Native 0.45.0+
  'Core',
  'DevSupport'
  # Add any other subspecs you want to use in your project
]

Now the react-native run-ios build "succeeds." However, I'm still seeing the same bundling issue:

Bundling `index.ios.js`  [development, non-minified, hmr disabled]  0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `/Users/samuelainsworth/Development/ReactNativePlayground/index.ios.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them: 

  * `/Users/samuelainsworth/Development/ReactNativePlayground/ios/Pods/React/package.json`
  * `/Users/samuelainsworth/Development/ReactNativePlayground/node_modules/react-native/package.json`

Here's the simulator perspective:
screen shot 2017-09-16 at 1 30 15 am

@olivierlesnicki
Copy link

Seeing same issue as @samuela

@olivierlesnicki
Copy link

For some reason the install process also creates a React folder under /ios/Pods, deleting it fixes the issue:
microsoft/react-native-code-push#745

@samuela
Copy link
Author

samuela commented Sep 18, 2017

@olivierlesnicki My understanding is that the /ios/Pods/React/ folder is brought into existence because of the

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

bit in the Podfile. Are you sure it's safe to delete it?

@JackThomson2
Copy link
Contributor

JackThomson2 commented Sep 21, 2017

Hi guys I had a similar issue with you but it was to do with archiving try adding this at the bottom of your pod file:

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

@chrisbianca
Copy link
Contributor

chrisbianca commented Sep 22, 2017

Docs have been updated with @JackThomson2's fix above which has been confirmed to work in certain situations. Please re-open if this is still an issue.

With v3.x we are looking at getting react-native link to work again - unfortunately basic support provided by React doesn't give us the right level of customisation for Android, but we'll figure something out.

@johnernaut
Copy link

johnernaut commented Sep 26, 2017

Hi, I've added the fix described by @JackThomson2 for this in my Podfile, and I've confirmed that Pods/React does not exist, but I'm still getting the following error from the react packager:

Bundling `index.ios.js`  [development, non-minified, hmr disabled]  0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module `/Users/<user>/code/RMMobile/index.ios.js` tries to require `react-native`, but there are several files providing this module. You can delete or fix them:
* `/Users/<user>/code/RMMobile/ios/Pods/React/package.json`
* `/Users/<user>/code/RMMobile/node_modules/react-native/package.json`

I've also made sure my React pod path is pointed into my node_modules directory for reference.

Any ideas?

EDIT:

I was able to resolve this issue by clearing the react packager cache.

@bramus
Copy link

bramus commented Sep 29, 2017

Referencing software-mansion/react-native-svg#463

@staufman
Copy link

staufman commented Oct 4, 2017

If anyone else is seeing there, it may be because the block of code in the Podfile (see the post a few above this one) which removes React was added after running pod install once. In this case, the React pod will be in your Pods/ directory and it will not be removed after running pod install. In short, try deleting your Pods/ directory and then run pod install. You will most likely need to reset your cache too i.e. npm start -- --reset-cache.

@bramus
Copy link

bramus commented Oct 25, 2017

Had the same issue. Running all typical sh*tfix-commands (watchman watch-del-all, rm -rf $TMPDIR/react-*, yarn cache clean && rm -rf node_modules/ && yarn install, etc) had no result.

Restarting my Mac eventually fixed it for me ¯\_(ツ)_/¯

@brenmcnamara
Copy link

I added the code snippet commented above and it fixed the issue, however I am getting 3 new warnings that I think are related to this:

  1. Pods-<Project Name>: Missing dependency target 'React'
  2. Apple Mach-O Linker Warning:
directory not found for option:
'-L\~/Library/Developer/Xcode/DerivedData/<Project Name>-brqiwtorgjqxrhcepigoefhmtcve/Build/Products/Debug-iphonesimulator/React'
  1. The same warning as above, but for the test target.

I've tried the following:

yarn cache clean
watchman watch-del-all
rm -rf node_modules && yarn install
cd ios && rm -rf Pods && pod install
Clean xcode build, clean xcode build folders
Resetting the simulator to its default settings
Restarting my computer

None of those helped. Is anyone else seeing these warnings, or has any idea how to make them go away?

Thanks in advance!

@shyamady
Copy link

shyamady commented Feb 22, 2018

I have the same problem and fixed it yet.

  1. deleted ios/Pods
  2. Restart your Mac
  3. Pod install on ios/Pods

And I removed them.

  # pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
  #
  # pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

@MaheshNandam
Copy link

I have fixed this issue by 'npm start -- --reset-cache' command.

@allanjsx
Copy link

allanjsx commented May 10, 2018

I fixed it by adding below lines to the pod file, to make sure CocoaPod gets React dependency from node_modules instead of creating a new directory and pulling from other repo.

  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

And in my case, I make sure that I also DON'T have the above suggested:

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

so that the libs can be properly linked to my project.

@Nonnis-M
Copy link

@allanjsx is the only solution that fix the problem for me after I have spent 2 days searching around...

Anyway I'm struggling understand why on another machine (Mac osx) with same project configuration and same cocoapod version (1.40) the pod install command does not generate the React dependency and all works perfectly...

@CreativeArtDev
Copy link

CreativeArtDev commented Aug 31, 2018

pod 'React', :path => '../node_modules/react-native'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
end
end

If someone can not build even though try this,
please update the pod.
pod update

@wikieswan
Copy link

@MobileWojciec as you say, pod update works for me

@mahendrathotakura
Copy link

I am also having the same issue.

bundling failed: ambiguous resolution: module /Users/**/**/index.js tries to require react-native, but there are several files providing this module. You can delete or fix them:

  • /Users/**/**/ios/Pods/React/package.json
  • `/Users///node_modules/react-native/package.json

Can you please help me out

@CreativeArtDev
Copy link

@mahendrathotakura Can you show the detailed environment of your app?

@mahendrathotakura
Copy link

@mahendrathotakura Can you show the detailed environment of your app?

Thanks for your response! I fixed the issue, it is due to Pods.

@FelipeSSantos1
Copy link

The complete solution to solve this, your Podfile should look likes that example below. After alter the file you have to do a pod update

 platform :ios, '9.0'

 install! 'cocoapods', :deterministic_uuids => false

target 'yourproject' do
  rn_path = '../node_modules/react-native'
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]

  # Pods for yourproject
  pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    # The following is needed to ensure the "archive" step works in XCode.
    # It removes React & Yoga from the Pods project, as it is already included in the main project.
    # Without this, you'd see errors when you archive like:
    # "Multiple commands produce ... libReact.a"
    # "Multiple commands produce ... libyoga.a"

    targets_to_ignore = %w(React yoga)

    if targets_to_ignore.include? target.name
      target.remove_from_project
    end
  end
end

@ThomasGHenry
Copy link

I was getting the "Multiple commands produce ..." for libRNFirebase.a and seem to have solved it based on this facebook/react-native#20492 (comment)

@leron8
Copy link

leron8 commented May 31, 2019

Omg I was struggling with this for two days. I did what @allanjsx said in his comment but I deleted the Pod directory and then pod install. That recreated the whole directory with the correct reference to React in node_modules.

@mikehardy
Copy link
Collaborator

You guys might like the addition I just made to react-native-clean-project - after you install that module you just run react-native clean-project-auto and it purges all the react-native state (including pod) that I'm aware of. You have to reinstall node and pod packages afterwards, but before tearing hear out, it's a good thing to try...

@stereodenis
Copy link

cd android && ./gradlew clean helps me

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