Search code examples
iosreact-nativecocoapodspodfile

Increasing IOS platform version throws error for react-native-maps, reducing it throws error for other react-native libraries


I'm writing tests for my react-native application, but it fails, suggesting I run pod install. After running pod install, I get

!] CocoaPods could not find compatible versions for pod "GoogleMaps":
  In Podfile:
    react-native-google-maps (from `../node_modules/react-native-maps`) was resolved to 0.27.1, which depends on
      GoogleMaps (= 3.5.0)

    react-native-google-places (from `../node_modules/react-native-google-places`) was resolved to 3.1.2, which depends on
      GoogleMaps (~> 3.1.0)

Specs satisfying the `GoogleMaps (~> 3.1.0), GoogleMaps (= 3.5.0)` dependency were found, but they required a higher minimum deployment target.

Reducing my deployment target, however to 9.0 throws another error:

!] CocoaPods could not find compatible versions for pod "React-jsiexecutor":
  In Podfile:
    React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)

Specs satisfying the `React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)` dependency were found, but they required a higher minimum deployment target.

with the first error gone.

Here's what my pod file looks like:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'MonkeyMusic' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  pod 'GoogleMaps', '~> 3.1.0'
  pod 'Google-Maps-iOS-Utils'
  pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
  pod 'react-native-google-places', :path => '../node_modules/react-native-google-places'

  target 'MonkeyMusicTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  # use_flipper!({ 'Flipper-Folly' => '2.3.0' })
  post_install do |installer|
    flipper_post_install(installer)
    installer.pods_project.targets.each do |target|
      if target.name == 'react-native-google-places'
        target.build_configurations.each do |config|
          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
           config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
           # config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET
           config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
          end
      end
      if target.name == "React"
        target.remove_from_project
      end
    end
  end
 
end

target 'MonkeyMusic-tvOS' do
  # Pods for MonkeyMusic-tvOS

  target 'MonkeyMusic-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

I'll be glad if this can be resolved. It has stolen more than 12hours development time.


Solution

  • Ok, I'm not an expert in React Native, but I do know how the Cocoapods are working and it looks like there's a conflict of versions because react-native-google-places requires GoogleMaps with version ~> 3.1.0 (which means 3.1.x) while react-native-google-maps needs it to be exactly 3.5.0. You could check this in the modules podspec files:

    • node_modules/react-native-google-places/react-native-google-places.podspec
    • node_modules/react-native-maps/react-native-google-maps.podspec

    I don't see a way to solve this from the pod file because it's either some issue with modules install or an outdated podspec file configuration.

    In general such conflicts are resolved by upgrading or downgrading one of the pods dependencies. So in your case just to make it work you could go to react-native-google-places.podspec and update the dependencies there to this:

    s.dependency 'GooglePlaces', '~> 3.5.0'
    s.dependency 'GoogleMaps', '~> 3.5.0'
    

    It's not an ideal solution because obviously it should be fixed in the original podspec source file, but it may be helpful if you just want to make it work.

    Also there could be a bit better solution with a use of patch-package mentioned in this thread which is actually about the issue you have.