iOS: React Native 版本 0.72.1 -> 找不到 'react/debug/react_native_assert.h' 文件错误。

4
我遇到了一个错误:找不到'react/debug/react_native_assert.h'文件,以及React-utils/RunLoopObserver。问题似乎是我添加的一个pre_install钩子引起的。
dynamic_frameworks = [
    'Starscream',
    'iProov',
    'DatadogSDK',
    'SwiftProtobuf',
]
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if !dynamic_frameworks.include?(pod.name)
      puts "Overriding the static_framework? method for #{pod.name}"
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

I cannot remove the pre_install hook as it is required to run one of my dependencies

很多人似乎都遇到了这个问题。你可以在这里关注Github上的更新: https://github.com/facebook/react-native/issues/38283 (目前还没有解决方案) - undefined
1个回答

0
对于RN 0.72.6,我能够通过在Podfile中添加下面的行,删除Pods文件夹并再次运行pod install来修复这个问题:
1. 添加append_header_search_path def

  # Note that there is a space character after `$(inherited)`

  def append_header_search_path(target, path)
      target.build_configurations.each do |config|
          
          config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) "
          config.build_settings["HEADER_SEARCH_PATHS"] << path
      end
  end

2. 在 post_install 中,以以下方式调用函数,并确保包含所有触发错误的库。

  post_install do |installer|

   flipper_post_install(installer)

    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )

   __apply_Xcode_12_5_M1_post_install_workaround(installer)

   # ---------------------- Calling the function here -----------------

   installer.pods_project.targets.each do |target|
    if ["React-cxxreact", "React-NativeModulesApple", "RNGestureHandler", "RNScreens", "React-utils", "React-runtimescheduler"].any? { |t| t == target.name }
      append_header_search_path(target, "${PODS_ROOT}/../../node_modules/react-native/ReactCommon")
    end
   end

  # ...



来源:

https://github.com/software-mansion/react-native-svg/issues/2081#issuecomment-1656701180

https://github.com/facebook/react-native/issues/38283#issuecomment-1667457797


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接