Cocoapods always install old React (0.11.0)

Viewed 4644

I have a problem when I run pod install Pod always downgrade React Installing React 0.11.0 (was 0.55.4)

my pod file:

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '9.0'
project 'BunteMobile.xcodeproj'
target 'BunteMobile' do
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for BunteMobile
  pod 'Adjust', '~> 4.8.3'
  pod 'Google-Mobile-Ads-SDK'
  pod 'GoogleAds-IMA-iOS-SDK', '~> 3.7'
  pod 'Fabric', '~> 1.7.0'
  pod 'Crashlytics', '~>  3.9'

  pod 'lottie-ios', :path => '../node_modules/lottie-ios'

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

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

end

I read about some solution when I defined react folder from node_modules but this solution doesn't work for me too.

I put into podfile this:

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

but still doesn't work. Downgrade disappear but when I try to build it, I have this error:

/node_modules/react-native/React/Base/RCTConvert.h:17:9: could not build module 'yoga'

I tried the same profile as official RN doc (https://facebook.github.io/react-native/docs/integration-with-existing-apps.html) but still same error.


Solution

I added this into my podfile:

# Pods for React-Native start
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'

(update 2019)Solution 2 (react-native 0.61+): add this to pod file

  # Pods for React-Native start
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  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-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  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 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  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'
2 Answers

Just remove the node_modules lines from pod file and add the library manually in xCode.

I observed that when you run react-native link <someLibrary> sometimes RN automatically adds that library as pod dependency.

In my case this error showed up for react-native-webview.

To fix it:

I just removed the node_modules/react-native-webview line from the pod file and then

Added that library in xCode near the other libraries

Drag node_modules/some_library/ios/RNCWebView.xcodeproj into project library files

enter image description here

Add the library dependencies in build phases link binary with libraries

enter image description here

If you're integrating RN into an existing native app, you'll want your podfile to look roughly like this. That is, you will specify the path to React dependency by pod 'React', :path => '../node_modules/react-native' ...

Are you developing a greenfield RN app? If so, you probably don't want to have pod 'lottie-react-native', :path => '../node_modules/lottie-react-native' in your podfile because it likely causes the trouble you're having.

Instead, go back to what your repo looked like before running react-native link lottie-react-native. This command likely added the pod 'lottie-react-native', :path => '../node_modules/lottie-react-native' line into your podfile. Now, you can follow manual installation instructions (that I see are not there, but you can check these, it will be the same thing) or you can do the following: remove lottie-react-native.podspec from node_modules/lottie-react-native and only then run react-native link lottie-react-native. The dependency won't be added to podfile but instead linked into the binary as a static lib.

Related