React Native 0.72.1 iOS端报'react/debug/react_native_assert.h'文件找不到错误
解决'react/debug/react_native_assert.h'文件找不到的问题
问题根源
你的pre_install钩子强制将绝大多数Pod改为静态库,但React Native的核心模块(如React-utils)需要保持动态库属性才能正确暴露头文件,强制静态后导致编译时找不到相关头文件。
解决方案
1. 修改pre_install钩子,排除React Native核心模块
更新Podfile中的pre_install逻辑,跳过React相关的Pod,不强制修改它们的静态/动态属性:
dynamic_frameworks = [ 'Starscream', 'iProov', 'DatadogSDK', 'SwiftProtobuf', ] pre_install do |installer| installer.pod_targets.each do |pod| # 跳过指定动态库和所有React/RCT开头的核心模块 next if dynamic_frameworks.include?(pod.name) || pod.name.start_with?('React') || pod.name.start_with?('RCT') 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
2. 清理缓存并重新安装依赖
执行以下命令彻底清理并重新安装Pods:
pod deintegrate rm -rf Podfile.lock Pods pod install
3. 验证Header Search Paths(可选)
如果问题仍存在,检查项目Build Settings中的Header Search Paths是否包含以下路径(设置为recursive):
$(SRCROOT)/Pods/React$(SRCROOT)/Pods/ReactCommon
内容的提问来源于stack exchange,提问作者Maksi Bajo
相关产品推荐
相关产品推荐

