react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

React pod has been deprecated and build fails

Open samuela opened this issue 9 years ago • 27 comments

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 avatar Sep 16 '17 04:09 samuela

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 avatar Sep 16 '17 04:09 samuela

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 avatar Sep 16 '17 05:09 samuela

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

samuela avatar Sep 16 '17 05:09 samuela

Seeing same issue as @samuela

olivierlesnicki avatar Sep 16 '17 21:09 olivierlesnicki

For some reason the install process also creates a React folder under /ios/Pods, deleting it fixes the issue: https://github.com/Microsoft/react-native-code-push/issues/745

olivierlesnicki avatar Sep 17 '17 07:09 olivierlesnicki

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

samuela avatar Sep 18 '17 03:09 samuela

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

JackThomson2 avatar Sep 21 '17 11:09 JackThomson2

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.

chrisbianca avatar Sep 22 '17 08:09 chrisbianca

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.

johnernaut avatar Sep 26 '17 13:09 johnernaut

Referencing https://github.com/react-native-community/react-native-svg/issues/463

bramus avatar Sep 29 '17 12:09 bramus

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.

staufman avatar Oct 04 '17 18:10 staufman

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 ¯\_(ツ)_/¯

bramus avatar Oct 25 '17 15:10 bramus

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!

brenmcnamara avatar Nov 19 '17 19:11 brenmcnamara

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'

shyamady avatar Feb 22 '18 00:02 shyamady

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

MaheshNandam avatar Apr 06 '18 11:04 MaheshNandam

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.

allanjsx avatar May 10 '18 18:05 allanjsx

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

Nonnis-M avatar Jun 26 '18 11:06 Nonnis-M

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

CreativeArtDev avatar Aug 31 '18 02:08 CreativeArtDev

@MobileWojciec as you say, pod update works for me

wikieswan avatar Sep 29 '18 04:09 wikieswan

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

mahendrathotakura avatar Oct 24 '18 08:10 mahendrathotakura