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

React Native iOS项目集成Google SignIn时构建失败求助

iOS集成React Native Google SignIn构建失败问题

我正在尝试为iOS应用集成React Native Google SignIn,但构建时出现大量错误,无法完成构建。已经参考多个示例应用的文档操作,也试过搜索到的所有解决方案,均无效。

Podfile内容

platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false

production = ENV["PRODUCTION"] == "1"

target 'ExampleApp' do
  config = use_native_modules!
  use_modular_headers!
  pod 'GoogleSignIn', '~> 6.2.2'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :production => production,
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    :flipper_configuration => FlipperConfiguration.enabled,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'BarberAppTests' do
    inherit! :complete
    # Pods for testing
  end
 
  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

构建错误截图

构建错误截图

针对性解决步骤

  • 移除全局use_modular_headers!,GoogleSignIn 6.x与全局模块化头文件存在兼容性问题。如果其他依赖需要模块化头,单独为对应pod添加:modular_headers => true。
  • 删除手动添加的pod 'GoogleSignIn', '~> 6.2.2',react-native-google-signin库会自动管理GoogleSignIn依赖,手动添加易导致版本冲突。
  • 清理CocoaPods缓存并重新安装:
    pod deintegrate
    pod cache clean --all
    rm -rf Podfile.lock
    pod install
    
  • 注释掉post_install中的__apply_Xcode_12_5_M1_post_install_workaround(installer),该脚本仅适配旧版Xcode(12.5),若当前Xcode版本更高,会引发构建错误。
  • 检查Xcode项目设置:确保iOS Deployment Target与Podfile中platform :ios, '12.4'一致,同时在Build Settings的Other Linker Flags中添加-ObjC。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 10:06:25