You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS构建提示UMReactNativeAdapter/UMModuleRegistryAdapter.h找不到

问题根因

你开启了use_frameworks!全局配置,UMReactNativeAdapter默认按动态库编译,公出头文件的搜索路径没有被正确添加到主项目的编译配置中,同时和RNPermissions等静态依赖库存在编译类型冲突,最终导致头文件找不到。

解决方案

1. 清理缓存并重装依赖

先关闭Xcode,依次执行以下命令清理环境:

rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ios/Pods ios/Podfile.lock
rm -rf node_modules
npm install
cd ios && pod install --repo-update

2. 修正Podfile配置

调整Podfile的规则,强制UM系列依赖库按静态库编译:

  • 将use_unimodules!的位置移动到use_frameworks!之后、所有React相关pod声明之前
  • 在你现有pre_install代码的最上方,补充UM相关库的静态编译配置:
$static_um_pods = ['UMReactNativeAdapter', 'UMCore', 'UMModuleRegistry', 'UMPermissionsInterface']
installer.pod_targets.each do |pod|
  if $static_um_pods.include?(pod.name)
    def pod.build_type;
      Pod::Target::BuildType.static_library
    end
  end
end

你原有pre_install中关于UMPermissionsInterface、UMReactNativeAdapter的依赖补充逻辑可以保留,和上面的配置不冲突。

3. 手动添加头文件搜索路径

如果完成前两步后仍然报错,打开Xcode进入主target的Build Settings,找到Header Search Paths配置项,添加如下路径并设置为recursive:

"${PODS_ROOT}/Headers/Public/UMReactNativeAdapter"

4. 低版本兼容处理

如果你使用的react-native-unimodules版本低于0.12.0,将AppDelegate.m中的头文件引入写法替换为相对路径引用:

// 替换掉原来的#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
#import "UMModuleRegistryAdapter.h"

内容的提问来源于stack exchange,提问作者Naoya Nakamura

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 19:06:08