更新了 React Native,在 Podfile 中找不到 'boost' 依赖项

Updated React Native, can't find 'boost' dependency in Podfile

正如我的问题标题中提到的,我正在尝试 运行 pod install 在更新到 React Native 0.66 之后,但我不断收到以下错误:

[!] CocoaPods could not find compatible versions for pod "boost":
  In Podfile:
    RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) was resolved to 2021.06.28.00-v2, which depends on
      boost

    React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) was resolved to 0.66.0, which depends on
      boost (= 1.76.0)

Specs satisfying the `boost (= 1.76.0), boost` dependency were found, but they required a higher minimum deployment target.

我已经在 high-and-low 中搜索了另一个引用 'boost' 的问题,但我无法在任何地方找到它。我已经安装 boost-for-react-native 并添加到我的 Podfile,但它似乎没有解决任何问题。

如果我将 Podfile 中的部署目标更改为 11.0 甚至 14.0,我仍然会遇到错误。

这完全阻止了我的项目构建,所以如果我能得到任何类型的帮助那就太好了。

下面是完整的 Podfile:

platform :ios, '11.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'manager' do
  # Pods for manager
  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/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 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"
  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 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'

  pod 'React-perflogger', :path => '../node_modules/react-native/ReactCommon/reactperflogger'
  pod 'React-runtimeexecutor', :path => '../node_modules/react-native/ReactCommon/runtimeexecutor'
  pod 'boost-for-react-native', :podspec => 'https://raw.githubusercontent.com/react-native-community/boost-for-react-native/master/boost-for-react-native.podspec'


  # pod 'RNExtractColor', :path => '../node_modules/react-native-extract-color'

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

  # pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

  # pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'

  # pod 'react-native-view-shot', :path => '../node_modules/react-native-view-shot'

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

  use_native_modules!
end

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

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

end

post_install do |installer|
  ## Fix for XCode 12.5 beta
  find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
  "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")

  installer.pods_project.targets.each do |target|

    # The following is needed to ensure the "archive" step works in XCode.
    # It removes React & Yoga from the Pods project, as it is already included in the main project.
    # Without this, you'd see errors when you archive like:
    # "Multiple commands produce ... libReact.a"
    # "Multiple commands produce ... libyoga.a"

    targets_to_ignore = %w(React yoga)
    
    if targets_to_ignore.include? target.name
      target.remove_from_project
    end

  end
end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

我最近在更新 React Native 后遇到了与 boost 类似的问题。在恐慌消退并喝了一些好咖啡之后,我可以通过执行以下操作来解决问题:

  1. 打开 Xcode 中的 <app_name>/ios/<app_name>.xcworkspace 文件。
  2. 提高 iOS 部署目标(在我的例子中,我只达到了 10)。
  3. 产品 > 清理构建文件夹,然后是产品 > 运行。
  4. 在问题导航器中找到提升错误并确定错误列在哪个 pod 下(在我的例子中是 RNReanimated)。
  5. 更新与pod相关的节点包(在我的例子中,npm update react-native-reanimated
  6. 最后,运行pod install

执行完这些步骤后,我能够启动我的项目并再次 运行ning。

我升级到 react-native 0.66.4 时遇到了同样的问题。从字面上得到确切的错误消息。

我的 Podfile 中缺少以下行:

pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'

添加完后,我 运行 pod install 问题就解决了!