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

RN iOS编译报错:在google命名空间内导入'glog.glog.log_severity'模块

解决RN iOS构建报错:Import of module 'glog.glog.log_severity' appears within namespace 'google'

问题描述

在Xcode构建React Native iOS应用时,触发报错:Import of module 'glog.glog.log_severity' appears within namespace 'google',报错代码位于logging.h的google命名空间片段中:

namespace google {

// They need the definitions of integer types.
#include "glog/log_severity.h"
#include "glog/vlog_is_on.h"

曾尝试在Podfile中添加以下配置(单独或组合使用),但问题未得到解决:

use_modular_headers!

pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false
pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec', :modular_headers => false

可行解决办法

  • 方法1:修改glog的podspec配置
    找到node_modules/react-native/third-party-podspecs/glog.podspec文件,添加以下配置:

    spec.pod_target_xcconfig = {
      'DEFINES_MODULE' => 'NO',
      'CLANG_MODULES_AUTOLINK' => 'NO'
    }
    

    保存后执行pod install,重新构建项目。

  • 方法2:调整Xcode模块设置

    1. 打开Xcode项目,找到Pods项目下的glog目标
    2. 进入「Build Settings」,搜索「Defines Module」,设置为NO
    3. 搜索「Enable Modules (C and Objective-C)」,设置为NO
    4. 执行Cmd+Shift+K清理项目,重新构建
  • 方法3:清理缓存后重装依赖

    1. 删除项目根目录下的Pods文件夹和Podfile.lock文件
    2. 执行pod deintegrate
    3. 执行pod install --repo-update
    4. 执行Cmd+Option+Shift+K清理Xcode缓存,重新构建
  • 方法4:调整React Native版本
    如果上述方法无效,可尝试将RN版本切换到已知无此问题的版本:

    • 降级至0.71.x系列
    • 升级至0.72.x及以上版本(部分用户反馈新版本已修复该问题)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 15:30:05