“您的 Podfile 需要安装插件 `cocoapods-patch`”

问题描述 投票:0回答:1

在获得一台配备 MacOS Monterey 12.2.1 (21D62) 和 XCode 版本 13.4.1 (13F100) 的新 M1 Macbook 后,当我在 React Native 项目中运行

cd ios
pod install
时,我得到:

[!] 您的 Podfile 需要安装插件

cocoapods-patch
。请安装并再次尝试安装。

我已经寻找解决方案。

全局安装“cocoapods-patch”没有任何区别。

自去年以来,“cocoapods-patch”没有新的更新。

显然可以强制 XCode 12 在蒙特雷工作,这应该可行,但这不是一个合适的解决方案。最终我需要更新到 XCode 13。

有什么想法吗?谢谢你。

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

在“pod install --verbose”之后登录:

Installing unimodules:
 [email protected] from ../node_modules/expo-constants/ios
 [email protected] from ../node_modules/expo-file-system/ios
 [email protected] from ../node_modules/expo-image-loader/ios
 [email protected] from ../node_modules/expo-in-app-purchases/ios
 [email protected] from ../node_modules/expo-modules-core/ios
 [email protected] from ../node_modules/unimodules-app-loader/ios
 [email protected] from ../node_modules/@unimodules/core/ios
 [email protected] from ../node_modules/@unimodules/react-native-adapter/ios
 [email protected] 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

我想补充一点,当我执行

pod
时,我没有收到
patch
命令,就像根本没有安装cocoapods-patch一样。但我已经做过很多次
sudo gem install cocoapods-patch
了。

ios xcode react-native cocoapods
1个回答
0
投票

2023 年更新

我再次遇到这个问题,这次对我有用的是相反的方法,卸载所有内容并使用 Gem 安装。

sudo gem uninstall cocoapods cocoapods-patch

sudo brew uninstall cocoapods cocoapods-patch

sudo gem install cocoapods cocoapods-patch

经过以下步骤后问题已得到解决:

sudo gem uninstall cocoapods cocoapods-patch

sudo brew uninstall cocoapods cocoapods-patch

sudo brew install cocoapods cocoapods-patch

基本上卸载所有内容并用brew重新安装。看来我已经安装了带有 gem 的 cocoapods 和带有brew 的 cocoapods-patch 或相反。

© www.soinside.com 2019 - 2024. All rights reserved.