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

升级Xcode 15后Flutter iOS编译报错:找不到指定类方法

解决Xcode 15下Flutter iOS应用Google Maps ARC语义错误

问题核心

你遇到的mapIDWithIdentifier:和mapWithFrame:mapID:camera:找不到的ARC错误,本质是当前依赖的google_maps_flutter_ios 2.3.1版本不兼容Xcode 15及新版Google Maps SDK——这些方法是旧版SDK的API,新版已废弃或变更。

可行解决方案

  • 强制升级google_maps_flutter_ios到兼容版本
    google_maps_flutter 2.5.0默认依赖旧版google_maps_flutter_ios,需手动指定更高的兼容版本:
    在项目的pubspec.yaml中添加子依赖指定:

    dependencies:
      google_maps_flutter: ^2.5.0
      google_maps_flutter_ios: ^2.6.0 # 建议用2.6.0及以上版本
    

    执行以下命令更新依赖:

    flutter pub get
    cd ios
    pod install --repo-update
    
  • 强制指定Google Maps SDK版本
    如果上述方法无效,直接在iOS目录的Podfile中锁定新版Google Maps SDK:

    platform :ios, '13.0'
    target 'Runner' do
      use_frameworks!
      use_modular_headers!
    
      flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
      
      # 强制指定兼容Xcode15的SDK版本
      pod 'GoogleMaps', '~> 7.0'
      pod 'GoogleMapsBase', '~> 7.0'
      pod 'GoogleMapsCore', '~> 7.0'
    end
    

    然后执行清理重建:

    cd ios
    pod deintegrate
    pod install
    flutter clean
    flutter run
    
  • 调整模拟器架构设置
    Xcode15对模拟器架构的处理有变化,可修改Podfile移除arm64模拟器的排除限制:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        target.build_configurations.each do |config|
          # 清空模拟器架构排除列表
          config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = ''
        end
      end
    end
    

    重新执行pod install后再尝试构建。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 00:38:27