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

iOS项目集成Firebase Analytics遇C函数声明弃用错误求助

解决Firebase Analytics中“A function declaration without a prototype is deprecated”错误

问题场景

iOS项目集成Firebase Analytics后,运行时触发编译错误:A function declaration without a prototype is deprecated in all versions of C,错误指向Firebase依赖库中的代码行GDTCORNetworkType GDTCORNetworkTypeMessage() {,执行pod update后问题仍存在,且为纯Xcode原生项目(非React Native)。

错误原因

该错误源于C语言标准变更:C11及更高版本要求函数声明必须明确参数列表(空参数需声明为void),而GDTCORNetworkTypeMessage()采用了旧式的空参数声明方式,在新的编译标准下被标记为废弃。

解决方法

  • 方法1:调整项目C语言编译标准

    1. 打开项目Target的Build Settings
    2. 搜索C Language Dialect,将其设置为GNU99 [-std=gnu99](GNU99标准兼容旧式函数声明)
    3. 重新编译项目
  • 方法2:针对Firebase依赖单独设置编译选项
    在Podfile中添加以下配置,仅对GoogleDataTransport库(错误来源库)设置兼容的编译标准:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name == 'GoogleDataTransport'
          target.build_configurations.each do |config|
            config.build_settings['CLANG_C_LANGUAGE_STANDARD'] = 'gnu99'
          end
        end
      end
    end
    

    执行pod install重新安装依赖后编译项目。

  • 方法3:指定适配Xcode版本的Firebase版本
    若当前Firebase版本与Xcode版本不兼容,可在Podfile中指定稳定兼容版本:

    pod 'Firebase/Analytics', '~> 10.17.0' # 替换为适配你Xcode版本的最新稳定版
    

    执行pod update Firebase/Analytics更新依赖后编译。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 11:47:20