Search code examples
iosxcodereact-nativecocoapods

"Your Podfile requires that the plugin `cocoapods-patch` be installed" after XCode 13 update


After getting a new M1 Macbook with MacOS Monterey 12.2.1 (21D62) and XCode Version 13.4.1 (13F100) when I run cd ios and pod install in a React Native project I'm getting:

[!] Your Podfile requires that the plugin cocoapods-patch be installed. Please install it and try installation again.

I already searched for solutions.

Globally installing 'cocoapods-patch' doesn't make any difference.

There are no new updated for 'cocoapods-patch' since last year.

Apparently it's possible to force XCode 12 to work in Monterey and this should work, but it's not a proper solution. Eventually I will need to update to XCode 13.

Any ideas? Thank you.

Podfile:

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

# source 'https://github.com/CocoaPods/Specs.git'
source 'https://cdn.cocoapods.org/'

platform :ios, '12.1.0'
plugin 'cocoapods-patch'

target 'MyProject' do
  use_unimodules!
  config = use_native_modules!
  pod 'Google-Mobile-Ads-SDK'
  pod 'GoogleToolboxForMac/NSString+HTML', '2.3.0'
  pod 'Mantle', '2.1.6'
  pod 'tealium-swift', '2.6.0' # all modules
  pod "tealium-react-native-swift", :path => '../node_modules/tealium-react-native/tealium-react-native-swift.podspec'

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => true
  )

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  # use_flipper!()

  #   post_install do |installer|
  #     react_native_post_install(installer)
  #   end
  # end
  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
    # Apple Silicon builds require a library path tweak for Swift library discovery or "symbol not found" for swift things
    installer.aggregate_targets.each do |aggregate_target| 
      aggregate_target.user_project.native_targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
          config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
        end
      end
      aggregate_target.user_project.save
    end

    # Flipper requires a crude patch to bump up iOS deployment target, or "error: thread-local storage is not supported for the current target"
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
       end
    end

    # ...but if you bump iOS deployment target, Flipper barfs again "Time.h:52:17: error: typedef redefinition with different types"
    # We need to make one crude patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1
    # https://github.com/facebook/flipper/issues/834 - 84 comments and still going...
    `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_12_0/' #{installer.sandbox.root}/RCT-Folly/folly/portability/Time.h`
  end
end

log after 'pod install --verbose':

Installing unimodules:
 expo-constants@11.0.2 from ../node_modules/expo-constants/ios
 expo-file-system@11.1.3 from ../node_modules/expo-file-system/ios
 expo-image-loader@2.2.0 from ../node_modules/expo-image-loader/ios
 expo-in-app-purchases@11.0.1 from ../node_modules/expo-in-app-purchases/ios
 expo-modules-core@0.2.0 from ../node_modules/expo-modules-core/ios
 unimodules-app-loader@2.2.0 from ../node_modules/unimodules-app-loader/ios
 unimodules-core@7.1.2 from ../node_modules/@unimodules/core/ios
 unimodules-react-native-adapter@6.3.9 from ../node_modules/@unimodules/react-native-adapter/ios
 unimodules-task-manager-interface@6.2.0 from ../node_modules/unimodules-task-manager-interface/ios

  $ /Users/ramiro/.nvm/versions/node/v14.15.0/bin/node -e try {console.log(require('@react-native-community/cli').bin);} catch (e)
  {console.log(require('react-native/cli').bin);}
  /Users/ramiro/mobile-darwin/node_modules/@react-native-community/cli/build/bin.js
RNFBAnalytics: Using default Firebase/Analytics with Ad Ids. May require App Tracking Transparency. Not allowed for Kids apps.
RNFBAnalytics: You may set variable `$RNFirebaseAnalyticsWithoutAdIdSupport=true` in Podfile to use analytics without ad ids.
Using firebase.json from '/Users/ramiro/mobile-darwin/firebase.json'
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration
Adding a custom script phase for Pod RNFBCrashlytics: [RNFB] Crashlytics Configuration
react-native-appsflyer: Using default AppsFlyerFramework.You may require App Tracking Transparency. Not allowed for Kids apps.
react-native-appsflyer: You may set variable `$RNAppsFlyerStrictMode=true` in Podfile to use strict mode for kids apps.
Auto-linking React Native modules for target `NewEspresso`: BVLinearGradient, RNBootSplash, RNCAsyncStorage, RNCMaskedView, RNColorMatrixImageFilters, RNDeviceInfo, RNFBAnalytics, RNFBApp, RNFBCrashlytics, RNFBFirestore, RNFBMessaging, RNFBPerf, RNFBRemoteConfig, RNFS, RNGestureHandler, RNKeychain, RNLocalize, RNPermissions, RNSVG, RNScreens, RNSentry, RNShare, RNSharedElement, RNVectorIcons, apptentive-react-native, react-native-ad-manager, react-native-appsflyer, react-native-background-downloader, react-native-background-timer, react-native-blur, react-native-mmkv-storage, react-native-netinfo, react-native-pager-view, react-native-photo-manipulator, react-native-safe-area-context, react-native-slider, react-native-track-player, react-native-view-shot, react-native-webview, and tealium-react-native
  Preparing
[!] Your Podfile requires that the plugin `cocoapods-patch` be installed. Please install it and try installation again.

/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:722:in `block in ensure_plugins_are_installed!'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:720:in `each'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:720:in `ensure_plugins_are_installed!'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:225:in `block in prepare'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:149:in `message'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:222:in `prepare'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:160:in `install!'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `<main>'

[!] use_native_modules! skipped the react-native dependency 'react-native-economist'. No podspec file was found.
    - Check to see if there is an updated version that contains the necessary podspec file
    - Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven podspec. See
    https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec
    - If necessary, you can disable autolinking for the dependency and link it manually. See
    https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library

I want to add that when I do pod, I'm not getting the patch command, it's like cocoapods-patch wasn't installed at all. But I already did sudo gem install cocoapods-patch many times.

pod commands available (patch is not here)


Solution

  • UPDATE 2023

    I bumped into this issue again and this time what worked for me was the other way around, uninstalling everything and installing with Gem.

    sudo gem uninstall cocoapods cocoapods-patch
    
    sudo brew uninstall cocoapods cocoapods-patch
    
    sudo gem install cocoapods cocoapods-patch
    

    OLD

    The issue was fixed after following steps:

    sudo gem uninstall cocoapods cocoapods-patch
    
    sudo brew uninstall cocoapods cocoapods-patch
    
    sudo brew install cocoapods cocoapods-patch
    

    Basically uninstalling everything and reinstalling with brew. It seems I had installed cocoapods with gem and cocoapods-patch with brew or the other way around.