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

Flutter iOS模拟器编译报错:Undefined symbols,移除google_mobile_ads后正常

解决google_mobile_ads: ^5.2.0导致iOS模拟器编译链接失败的问题

以下是针对该问题的实用解决步骤:

  • 检查Podfile配置

    1. 确保Podfile中指定的iOS最低版本不低于11.0(google_mobile_ads 5.x版本要求):
      platform :ios, '11.0'
      
    2. 在post_install阶段添加适配脚本,解决版本依赖和架构问题:
      post_install do |installer|
        installer.pods_project.targets.each do |target|
          flutter_additional_ios_build_settings(target)
          # 统一设置google_mobile_ads的部署版本
          if target.name == 'google_mobile_ads'
            target.build_configurations.each do |config|
              config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
            end
          end
        end
        # 针对M系列芯片模拟器排除arm64架构
        installer.pods_project.build_configurations.each do |config|
          config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
        end
      end
      
  • 清理缓存并重新构建
    执行以下命令彻底清理后重新安装依赖:

    flutter clean
    rm -rf ios/Pods ios/Podfile.lock
    flutter pub get
    cd ios && pod install --repo-update
    cd .. && flutter run
    
  • 检查Xcode项目链接配置
    打开ios/Runner.xcworkspace,进入Runner目标的Build Settings:

    1. 找到Other Linker Flags,确保包含-ObjC参数(AdMob框架依赖该参数)
    2. 检查Link Binary With Libraries中是否已添加AdSupport、CoreTelephony、StoreKit系统框架,若没有则手动添加
  • 尝试调整包版本
    如果以上步骤无效,可以尝试升级google_mobile_ads到最新稳定版,或降级到5.1.0版本,排除版本兼容性问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 06:02:44